답안 #287314

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
287314 2020-08-31T15:21:09 Z luciocf Snake Escaping (JOI18_snake_escaping) C++14
12 / 100
406 ms 20220 KB
#include <bits/stdc++.h>

using namespace std;

const int maxn = 10;

int n, q;
char v[1<<maxn];

int dp[1<<maxn][1<<maxn];

int main(void)
{
	ios::sync_with_stdio(false); cin.tie(0);

	cin >> n >> q;

	for (int i = 0; i < (1<<n); i++)
	{
		cin >> v[i];
		v[i] = (int)(v[i]-'0');
	}

	for (int fixo = (1<<n)-1; fixo >= 0; fixo--)
	{
		dp[fixo][0] = v[fixo];

		for (int outro = 1; outro < (1<<n); outro++)
		{
			int b;
			for (int l = 0; l < n; l++)
			{
				if (outro&(1<<l))
				{
					b = l;
					break;
				}
			}

			dp[fixo][outro] = dp[fixo][outro^(1<<b)] + dp[fixo|(1<<b)][outro^(1<<b)];
		}
	}

	while (q--)
	{
		int fixo = 0, outro = 0;

		for (int i = 0; i < n; i++)
		{
			char c;
			cin >> c;

			if (c == '?') outro += (1<<(n-i-1));
			else if (c == '1') fixo += (1<<(n-i-1));
		}

		cout << dp[fixo][outro] << "\n";
	}
}

Compilation message

snake_escaping.cpp: In function 'int main()':
snake_escaping.cpp:30:8: warning: 'b' may be used uninitialized in this function [-Wmaybe-uninitialized]
   30 |    int b;
      |        ^
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 4480 KB Output is correct
2 Correct 8 ms 4408 KB Output is correct
3 Correct 8 ms 4480 KB Output is correct
4 Correct 8 ms 4480 KB Output is correct
5 Correct 8 ms 4480 KB Output is correct
6 Correct 9 ms 4480 KB Output is correct
7 Correct 9 ms 4480 KB Output is correct
8 Correct 8 ms 4480 KB Output is correct
9 Correct 8 ms 4480 KB Output is correct
10 Correct 8 ms 4480 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 4480 KB Output is correct
2 Correct 8 ms 4408 KB Output is correct
3 Correct 8 ms 4480 KB Output is correct
4 Correct 8 ms 4480 KB Output is correct
5 Correct 8 ms 4480 KB Output is correct
6 Correct 9 ms 4480 KB Output is correct
7 Correct 9 ms 4480 KB Output is correct
8 Correct 8 ms 4480 KB Output is correct
9 Correct 8 ms 4480 KB Output is correct
10 Correct 8 ms 4480 KB Output is correct
11 Correct 344 ms 19224 KB Output is correct
12 Correct 345 ms 18932 KB Output is correct
13 Correct 362 ms 18168 KB Output is correct
14 Correct 360 ms 18200 KB Output is correct
15 Correct 361 ms 19268 KB Output is correct
16 Correct 387 ms 18424 KB Output is correct
17 Correct 406 ms 18544 KB Output is correct
18 Correct 260 ms 20220 KB Output is correct
19 Correct 337 ms 17144 KB Output is correct
20 Correct 351 ms 18876 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 4480 KB Output is correct
2 Correct 8 ms 4408 KB Output is correct
3 Correct 8 ms 4480 KB Output is correct
4 Correct 8 ms 4480 KB Output is correct
5 Correct 8 ms 4480 KB Output is correct
6 Correct 9 ms 4480 KB Output is correct
7 Correct 9 ms 4480 KB Output is correct
8 Correct 8 ms 4480 KB Output is correct
9 Correct 8 ms 4480 KB Output is correct
10 Correct 8 ms 4480 KB Output is correct
11 Correct 344 ms 19224 KB Output is correct
12 Correct 345 ms 18932 KB Output is correct
13 Correct 362 ms 18168 KB Output is correct
14 Correct 360 ms 18200 KB Output is correct
15 Correct 361 ms 19268 KB Output is correct
16 Correct 387 ms 18424 KB Output is correct
17 Correct 406 ms 18544 KB Output is correct
18 Correct 260 ms 20220 KB Output is correct
19 Correct 337 ms 17144 KB Output is correct
20 Correct 351 ms 18876 KB Output is correct
21 Runtime error 1 ms 512 KB Execution killed with signal 11
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 4480 KB Output is correct
2 Correct 8 ms 4408 KB Output is correct
3 Correct 8 ms 4480 KB Output is correct
4 Correct 8 ms 4480 KB Output is correct
5 Correct 8 ms 4480 KB Output is correct
6 Correct 9 ms 4480 KB Output is correct
7 Correct 9 ms 4480 KB Output is correct
8 Correct 8 ms 4480 KB Output is correct
9 Correct 8 ms 4480 KB Output is correct
10 Correct 8 ms 4480 KB Output is correct
11 Runtime error 6 ms 4768 KB Execution killed with signal 11
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 4480 KB Output is correct
2 Correct 8 ms 4408 KB Output is correct
3 Correct 8 ms 4480 KB Output is correct
4 Correct 8 ms 4480 KB Output is correct
5 Correct 8 ms 4480 KB Output is correct
6 Correct 9 ms 4480 KB Output is correct
7 Correct 9 ms 4480 KB Output is correct
8 Correct 8 ms 4480 KB Output is correct
9 Correct 8 ms 4480 KB Output is correct
10 Correct 8 ms 4480 KB Output is correct
11 Correct 344 ms 19224 KB Output is correct
12 Correct 345 ms 18932 KB Output is correct
13 Correct 362 ms 18168 KB Output is correct
14 Correct 360 ms 18200 KB Output is correct
15 Correct 361 ms 19268 KB Output is correct
16 Correct 387 ms 18424 KB Output is correct
17 Correct 406 ms 18544 KB Output is correct
18 Correct 260 ms 20220 KB Output is correct
19 Correct 337 ms 17144 KB Output is correct
20 Correct 351 ms 18876 KB Output is correct
21 Runtime error 1 ms 512 KB Execution killed with signal 11
22 Halted 0 ms 0 KB -