Submission #839687

# Submission time Handle Problem Language Result Execution time Memory
839687 2023-08-30T13:03:41 Z mat_jur Snake Escaping (JOI18_snake_escaping) C++14
5 / 100
2000 ms 14980 KB
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
auto&operator<<(auto &o, pair<auto, auto> p) {o << "(" << p.first << ", " << p.second << ")"; return o;}
auto operator<<(auto &o, auto x)->decltype(x.end(), o) {o<<"{"; for(auto e : x) o<<e<<", "; return o<<"}";}
#define debug(X) cerr << "["#X"]: " << X << '\n';
#else 
#define debug(X) ;
#endif
#define ll long long
#define all(v) (v).begin(), (v).end()
#define FOR(i,l,r) for(int i=(l);i<=(r);++i)
#define ROF(i,r,l) for(int i=(r);i>=(l);--i)
#define REP(i,n) FOR(i,0,(n)-1)
#define ssize(x) int(x.size())
#define fi first
#define se second
#define eb emplace_back

int main () {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int l, t;
	cin >> l >> t;
	int n = (1<<l);
	string val;
	cin >> val;
	REP(i, t) {
		string b;
		cin >> b;
		vector<int> q;
		int s = 0;
		REP(j, l) {
			if (b[j] == '?') q.eb(l-j-1);
			if (b[j] == '1') s += (1<<(l-j-1));
		}
		int res = 0;
		REP(bm, (1<<ssize(q))) {
			int x = s;
			REP(j, ssize(q)) {
				if (bm&(1<<j)) x += (1<<q[j]);
			}
			res += val[x]-'0';
		}
		cout << res << '\n';
	}
	
	return 0;
}

Compilation message

snake_escaping.cpp: In function 'int main()':
snake_escaping.cpp:27:6: warning: unused variable 'n' [-Wunused-variable]
   27 |  int n = (1<<l);
      |      ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 37 ms 332 KB Output is correct
9 Correct 1 ms 260 KB Output is correct
10 Correct 2 ms 324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 37 ms 332 KB Output is correct
9 Correct 1 ms 260 KB Output is correct
10 Correct 2 ms 324 KB Output is correct
11 Correct 453 ms 14980 KB Output is correct
12 Correct 977 ms 14752 KB Output is correct
13 Correct 277 ms 14028 KB Output is correct
14 Correct 289 ms 14052 KB Output is correct
15 Correct 777 ms 14976 KB Output is correct
16 Correct 395 ms 14168 KB Output is correct
17 Correct 413 ms 14180 KB Output is correct
18 Execution timed out 2052 ms 1328 KB Time limit exceeded
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 37 ms 332 KB Output is correct
9 Correct 1 ms 260 KB Output is correct
10 Correct 2 ms 324 KB Output is correct
11 Correct 453 ms 14980 KB Output is correct
12 Correct 977 ms 14752 KB Output is correct
13 Correct 277 ms 14028 KB Output is correct
14 Correct 289 ms 14052 KB Output is correct
15 Correct 777 ms 14976 KB Output is correct
16 Correct 395 ms 14168 KB Output is correct
17 Correct 413 ms 14180 KB Output is correct
18 Execution timed out 2052 ms 1328 KB Time limit exceeded
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 37 ms 332 KB Output is correct
9 Correct 1 ms 260 KB Output is correct
10 Correct 2 ms 324 KB Output is correct
11 Correct 1854 ms 3812 KB Output is correct
12 Execution timed out 2065 ms 3752 KB Time limit exceeded
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 37 ms 332 KB Output is correct
9 Correct 1 ms 260 KB Output is correct
10 Correct 2 ms 324 KB Output is correct
11 Correct 453 ms 14980 KB Output is correct
12 Correct 977 ms 14752 KB Output is correct
13 Correct 277 ms 14028 KB Output is correct
14 Correct 289 ms 14052 KB Output is correct
15 Correct 777 ms 14976 KB Output is correct
16 Correct 395 ms 14168 KB Output is correct
17 Correct 413 ms 14180 KB Output is correct
18 Execution timed out 2052 ms 1328 KB Time limit exceeded
19 Halted 0 ms 0 KB -