-
Notifications
You must be signed in to change notification settings - Fork 0
/
uva11736.cpp
61 lines (49 loc) · 1.23 KB
/
uva11736.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
const int MAXN = 40;
const int MAXV = 300;
string variable[MAXV];
int variableC[MAXV];
unsigned long long char_arr_to_i(string c) {
unsigned long long sum = 0;
int len = c.length();
for(int i = 0; i < len; ++i) {
sum = (sum << 1) + c[i] - '0' ;
}
return sum;
}
int main() {
int b, v, request;
while(cin >> b >> v) {
map<string, unsigned long long> varVV;
for(int i = 0; i < v; ++i) {
cin >> variable[i] >> variableC[i];
}
for(int i = 0; i < v; ++i) {
string v = "";
unsigned long long sum = 0;
for(int j = 0; j < variableC[i]; ++j) {
string t;
cin >> t;
v += t;
}
varVV[ variable[i] ] = char_arr_to_i(v);
}
cin >> request;
for(int i = 0; i < request; ++i) {
string temp;
cin >> temp;
cout << temp << "=";
if(varVV.find(temp) != varVV.end())
cout << varVV[temp];
cout << endl;
}
}
return 0;
}