답안 #125658

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
125658 2019-07-06T07:34:53 Z 임유진(#3071) Snake Escaping (JOI18_snake_escaping) C++14
22 / 100
416 ms 52084 KB
#include<stdio.h>

typedef long long lint;

lint ans[5000005];
char S[17000], T[1000005][20];

void f(int l, int d) {
	if(d == 1) return;
	f(l, d / 3);
	f(l + d / 3, d / 3);
	for(int i = 0; i < d / 3; i++) ans[l + d * 2 / 3 + i] = ans[l + i] + ans[l + d / 3 + i];
}

int main() {
	int L, Q;

	scanf("%d%d\n%s", &L, &Q, S);
	for(int i = 0; i < Q; i++) scanf("%s", T[i]);

	for(int i = 0; i < (1 << L); i++) {
		int t = 0;
		for(int j = L - 1; j >= 0; j--) t = 3 * t + ((i & (1 << j)) ? 1 : 0);
		//printf("i = %d, t = %d\n", i, t);
		ans[t] = S[i] - '0';
	}
	int t = 1;
	for(int j = 0; j < L; j++) t *= 3;
	f(0, t);

	//for(int i = 0; i < t; i++) printf("%lld ", ans[i]);
	//printf("\n");

	for(int i = 0; i < Q; i++) {
		t = 0;
		for(int j = 0; j < L; j++) {
			t = 3 * t;
			if(T[i][j] == '1') t++;
			else if(T[i][j] == '?') t += 2;
		}
		printf("%lld\n", ans[t]);
	}
	return 0;
}

Compilation message

snake_escaping.cpp: In function 'int main()':
snake_escaping.cpp:18:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d\n%s", &L, &Q, S);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
snake_escaping.cpp:19:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i = 0; i < Q; i++) scanf("%s", T[i]);
                             ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 760 KB Output is correct
2 Correct 2 ms 760 KB Output is correct
3 Correct 2 ms 760 KB Output is correct
4 Correct 2 ms 888 KB Output is correct
5 Correct 2 ms 760 KB Output is correct
6 Correct 3 ms 760 KB Output is correct
7 Correct 3 ms 888 KB Output is correct
8 Correct 3 ms 760 KB Output is correct
9 Correct 2 ms 888 KB Output is correct
10 Correct 3 ms 888 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 760 KB Output is correct
2 Correct 2 ms 760 KB Output is correct
3 Correct 2 ms 760 KB Output is correct
4 Correct 2 ms 888 KB Output is correct
5 Correct 2 ms 760 KB Output is correct
6 Correct 3 ms 760 KB Output is correct
7 Correct 3 ms 888 KB Output is correct
8 Correct 3 ms 760 KB Output is correct
9 Correct 2 ms 888 KB Output is correct
10 Correct 3 ms 888 KB Output is correct
11 Correct 262 ms 35128 KB Output is correct
12 Correct 228 ms 34808 KB Output is correct
13 Correct 257 ms 34040 KB Output is correct
14 Correct 253 ms 34184 KB Output is correct
15 Correct 247 ms 35192 KB Output is correct
16 Correct 278 ms 34296 KB Output is correct
17 Correct 277 ms 34284 KB Output is correct
18 Correct 227 ms 36092 KB Output is correct
19 Correct 257 ms 33144 KB Output is correct
20 Correct 284 ms 34908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 760 KB Output is correct
2 Correct 2 ms 760 KB Output is correct
3 Correct 2 ms 760 KB Output is correct
4 Correct 2 ms 888 KB Output is correct
5 Correct 2 ms 760 KB Output is correct
6 Correct 3 ms 760 KB Output is correct
7 Correct 3 ms 888 KB Output is correct
8 Correct 3 ms 760 KB Output is correct
9 Correct 2 ms 888 KB Output is correct
10 Correct 3 ms 888 KB Output is correct
11 Correct 262 ms 35128 KB Output is correct
12 Correct 228 ms 34808 KB Output is correct
13 Correct 257 ms 34040 KB Output is correct
14 Correct 253 ms 34184 KB Output is correct
15 Correct 247 ms 35192 KB Output is correct
16 Correct 278 ms 34296 KB Output is correct
17 Correct 277 ms 34284 KB Output is correct
18 Correct 227 ms 36092 KB Output is correct
19 Correct 257 ms 33144 KB Output is correct
20 Correct 284 ms 34908 KB Output is correct
21 Correct 326 ms 50052 KB Output is correct
22 Correct 279 ms 50296 KB Output is correct
23 Correct 377 ms 49276 KB Output is correct
24 Correct 373 ms 49144 KB Output is correct
25 Correct 322 ms 51056 KB Output is correct
26 Correct 400 ms 49656 KB Output is correct
27 Correct 410 ms 49528 KB Output is correct
28 Correct 267 ms 52084 KB Output is correct
29 Correct 317 ms 47992 KB Output is correct
30 Correct 350 ms 50296 KB Output is correct
31 Correct 359 ms 50040 KB Output is correct
32 Correct 416 ms 50108 KB Output is correct
33 Correct 334 ms 49016 KB Output is correct
34 Correct 399 ms 49160 KB Output is correct
35 Correct 408 ms 49760 KB Output is correct
36 Correct 247 ms 47992 KB Output is correct
37 Correct 262 ms 50232 KB Output is correct
38 Correct 332 ms 47992 KB Output is correct
39 Correct 394 ms 49272 KB Output is correct
40 Correct 376 ms 49220 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 760 KB Output is correct
2 Correct 2 ms 760 KB Output is correct
3 Correct 2 ms 760 KB Output is correct
4 Correct 2 ms 888 KB Output is correct
5 Correct 2 ms 760 KB Output is correct
6 Correct 3 ms 760 KB Output is correct
7 Correct 3 ms 888 KB Output is correct
8 Correct 3 ms 760 KB Output is correct
9 Correct 2 ms 888 KB Output is correct
10 Correct 3 ms 888 KB Output is correct
11 Runtime error 24 ms 10104 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 760 KB Output is correct
2 Correct 2 ms 760 KB Output is correct
3 Correct 2 ms 760 KB Output is correct
4 Correct 2 ms 888 KB Output is correct
5 Correct 2 ms 760 KB Output is correct
6 Correct 3 ms 760 KB Output is correct
7 Correct 3 ms 888 KB Output is correct
8 Correct 3 ms 760 KB Output is correct
9 Correct 2 ms 888 KB Output is correct
10 Correct 3 ms 888 KB Output is correct
11 Correct 262 ms 35128 KB Output is correct
12 Correct 228 ms 34808 KB Output is correct
13 Correct 257 ms 34040 KB Output is correct
14 Correct 253 ms 34184 KB Output is correct
15 Correct 247 ms 35192 KB Output is correct
16 Correct 278 ms 34296 KB Output is correct
17 Correct 277 ms 34284 KB Output is correct
18 Correct 227 ms 36092 KB Output is correct
19 Correct 257 ms 33144 KB Output is correct
20 Correct 284 ms 34908 KB Output is correct
21 Correct 326 ms 50052 KB Output is correct
22 Correct 279 ms 50296 KB Output is correct
23 Correct 377 ms 49276 KB Output is correct
24 Correct 373 ms 49144 KB Output is correct
25 Correct 322 ms 51056 KB Output is correct
26 Correct 400 ms 49656 KB Output is correct
27 Correct 410 ms 49528 KB Output is correct
28 Correct 267 ms 52084 KB Output is correct
29 Correct 317 ms 47992 KB Output is correct
30 Correct 350 ms 50296 KB Output is correct
31 Correct 359 ms 50040 KB Output is correct
32 Correct 416 ms 50108 KB Output is correct
33 Correct 334 ms 49016 KB Output is correct
34 Correct 399 ms 49160 KB Output is correct
35 Correct 408 ms 49760 KB Output is correct
36 Correct 247 ms 47992 KB Output is correct
37 Correct 262 ms 50232 KB Output is correct
38 Correct 332 ms 47992 KB Output is correct
39 Correct 394 ms 49272 KB Output is correct
40 Correct 376 ms 49220 KB Output is correct
41 Runtime error 24 ms 10104 KB Execution killed with signal 11 (could be triggered by violating memory limits)
42 Halted 0 ms 0 KB -