답안 #720031

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
720031 2023-04-07T09:42:49 Z dozer Snake Escaping (JOI18_snake_escaping) C++14
22 / 100
518 ms 34112 KB
#include <bits/stdc++.h>
using namespace std;
#define sp " "
#define endl "\n";
#define fastio() cin.tie(0), ios_base::sync_with_stdio(0)
#define pb push_back
#define pii pair<int, int>
#define st first
#define nd second
#define N 9005
//#define int long long

const int modulo = 1e9 + 7;


int arr[N], ans[1000006];

int32_t main()
{
	fastio();

	int l, q;
	cin>>l>>q;
	for (int i = 0; i < (1<<l); i++)
	{
		char tmp;
		cin>>tmp;
		arr[i] = tmp - '0';
	}

	vector<pair<pii, int>> que;

	for (int j = 1; j <= q; j++)
	{
		int s = 0, t = 0;
		for (int i = l - 1; i >= 0; i--)
		{
			char tmp;
			cin>>tmp;
			if (tmp == '?') t |= (1<<i);
			else if (tmp == '1') s |= (1<<i);
		}
		que.pb({{s, t}, j});
	}

	sort(que.begin(), que.end());

	for (int i = 0; i < q; i++)
	{
		int s = que[i].st.st, t = que[i].st.nd, ind = que[i].nd;
		if (i > 0)
		{
			if (s == que[i - 1].st.st && t == que[i - 1].st.nd)
			{
				ans[ind] = ans[que[i - 1].nd];
				continue;
			}
		}
		for (int j = t; j != 0; j = (j - 1) & t)
			ans[ind] += arr[s | j];
		ans[ind] += arr[s];
	}

	for (int i = 1; i <= q; i++)
		cout<<ans[i]<<endl;

	cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " seconds\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 402 ms 20380 KB Output is correct
12 Correct 413 ms 19992 KB Output is correct
13 Correct 376 ms 19332 KB Output is correct
14 Correct 394 ms 19380 KB Output is correct
15 Correct 425 ms 20388 KB Output is correct
16 Correct 403 ms 19496 KB Output is correct
17 Correct 399 ms 19484 KB Output is correct
18 Correct 260 ms 21276 KB Output is correct
19 Correct 326 ms 18348 KB Output is correct
20 Correct 401 ms 20176 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 402 ms 20380 KB Output is correct
12 Correct 413 ms 19992 KB Output is correct
13 Correct 376 ms 19332 KB Output is correct
14 Correct 394 ms 19380 KB Output is correct
15 Correct 425 ms 20388 KB Output is correct
16 Correct 403 ms 19496 KB Output is correct
17 Correct 399 ms 19484 KB Output is correct
18 Correct 260 ms 21276 KB Output is correct
19 Correct 326 ms 18348 KB Output is correct
20 Correct 401 ms 20176 KB Output is correct
21 Correct 472 ms 20576 KB Output is correct
22 Correct 468 ms 20520 KB Output is correct
23 Correct 425 ms 19564 KB Output is correct
24 Correct 446 ms 19392 KB Output is correct
25 Correct 487 ms 21404 KB Output is correct
26 Correct 495 ms 19824 KB Output is correct
27 Correct 507 ms 19752 KB Output is correct
28 Correct 314 ms 32112 KB Output is correct
29 Correct 367 ms 31788 KB Output is correct
30 Correct 480 ms 34112 KB Output is correct
31 Correct 518 ms 33852 KB Output is correct
32 Correct 493 ms 33784 KB Output is correct
33 Correct 416 ms 32724 KB Output is correct
34 Correct 448 ms 32788 KB Output is correct
35 Correct 501 ms 33276 KB Output is correct
36 Correct 282 ms 31708 KB Output is correct
37 Correct 466 ms 33744 KB Output is correct
38 Correct 365 ms 31856 KB Output is correct
39 Correct 449 ms 33100 KB Output is correct
40 Correct 455 ms 32824 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Runtime error 1 ms 468 KB Execution killed with signal 11
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 402 ms 20380 KB Output is correct
12 Correct 413 ms 19992 KB Output is correct
13 Correct 376 ms 19332 KB Output is correct
14 Correct 394 ms 19380 KB Output is correct
15 Correct 425 ms 20388 KB Output is correct
16 Correct 403 ms 19496 KB Output is correct
17 Correct 399 ms 19484 KB Output is correct
18 Correct 260 ms 21276 KB Output is correct
19 Correct 326 ms 18348 KB Output is correct
20 Correct 401 ms 20176 KB Output is correct
21 Correct 472 ms 20576 KB Output is correct
22 Correct 468 ms 20520 KB Output is correct
23 Correct 425 ms 19564 KB Output is correct
24 Correct 446 ms 19392 KB Output is correct
25 Correct 487 ms 21404 KB Output is correct
26 Correct 495 ms 19824 KB Output is correct
27 Correct 507 ms 19752 KB Output is correct
28 Correct 314 ms 32112 KB Output is correct
29 Correct 367 ms 31788 KB Output is correct
30 Correct 480 ms 34112 KB Output is correct
31 Correct 518 ms 33852 KB Output is correct
32 Correct 493 ms 33784 KB Output is correct
33 Correct 416 ms 32724 KB Output is correct
34 Correct 448 ms 32788 KB Output is correct
35 Correct 501 ms 33276 KB Output is correct
36 Correct 282 ms 31708 KB Output is correct
37 Correct 466 ms 33744 KB Output is correct
38 Correct 365 ms 31856 KB Output is correct
39 Correct 449 ms 33100 KB Output is correct
40 Correct 455 ms 32824 KB Output is correct
41 Runtime error 1 ms 468 KB Execution killed with signal 11
42 Halted 0 ms 0 KB -