Submission #943449

#TimeUsernameProblemLanguageResultExecution timeMemory
943449guechotjrhhSnake Escaping (JOI18_snake_escaping)C++14
12 / 100
1542 ms65536 KiB
#include<iostream> #include<string> using namespace std; #include<map> #include<string> #include<algorithm> #include<vector> using namespace std; #define all(x) x.begin(),x.end() string str; int n; map<string, int> mp; string its(int a, int l) { string res = ""; for (int i = 0; i < l; i++) { res += '0' + (a & 1); a >>= 1; } reverse(all(res)); return res; } int sti(string s) { int res = 0; for (int i = 0; i < n; i++) { res <<= 1; res += s[i] - '0'; } return res; } void rec(string s, int i) { if (s.size() == n) { if (i == -1) { mp[s] = str[sti(s)]-'0'; return; } int u = 0; s[i] = '0'; u = mp[s]; s[i] = '1'; u += mp[s]; s[i] = '?'; mp[s] = u; return; } rec(s + '0', i); rec(s + '1', i); rec(s + '?', s.size()); } void init(int N, int Q, string S) { n = N; str = S; rec("", -1); } int query(string A) { return mp[A]; } int main() { ios::sync_with_stdio(0); cin.tie(0); int N, Q; cin >> N >> Q; string S; cin >> S; init(N, Q, move(S)); for (int i = 0; i < Q; i++) { string A; cin >> A; cout << query(move(A)) << endl; } }

Compilation message (stderr)

snake_escaping.cpp: In function 'void rec(std::string, int)':
snake_escaping.cpp:32:15: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   32 |  if (s.size() == n) {
      |      ~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...