답안 #334272

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
334272 2020-12-08T22:36:56 Z Fischer Brunhilda’s Birthday (BOI13_brunhilda) C++14
63.6508 / 100
1000 ms 262148 KB
#include <bits/stdc++.h>
#define rep(x, y, z) for (int x = y; x < z; ++x)
#define reo(x, y) for (int x = 0; x < y; ++x)
using namespace std;
 
const int maxn = 1e7 + 10;
int head[maxn];
int val[3 * maxn];
int nxt[3 * maxn];
int T = 0;
int cnt[maxn];
int dp[maxn];
int p[100010];
 
int main() {
	int m, q;
	scanf("%d%d", &m, &q);
	memset(head, -1, sizeof head);
	for (int i = 0; i < m; ++i) {
		scanf("%d", p+i);
		for (int j=p[i]; j<maxn; j+=p[i]) {
			assert(T < 2 * maxn);
			nxt[T] = head[j];
			head[j] = T;
			val[T] = j - p[i];
			T++;
		}
	}
	int front = 0;
	cnt[0] = m;
	const int mx = 1e9;
	for (int i = 1; i < maxn; ++i) {
		for (int x = head[i]; ~x; x = nxt[x]) {
			cnt[i]++;
			cnt[val[x]]--;
		}
		while (front < i && cnt[front] == 0) front++;
		if (front == i) dp[i] = mx;
		else dp[i] = min(mx, dp[front] + 1);
	}
	while (q--) {
		int n;
		scanf("%d", &n);
		if (dp[n] > n) puts("oo");
		else printf("%d\n", dp[n]);
	}
	return 0;
}

Compilation message

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:17:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   17 |  scanf("%d%d", &m, &q);
      |  ~~~~~^~~~~~~~~~~~~~~~
brunhilda.cpp:20:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   20 |   scanf("%d", p+i);
      |   ~~~~~^~~~~~~~~~~
brunhilda.cpp:43:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   43 |   scanf("%d", &n);
      |   ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 146 ms 131820 KB Output is correct
2 Correct 246 ms 198380 KB Output is correct
3 Correct 194 ms 178284 KB Output is correct
4 Correct 128 ms 123756 KB Output is correct
5 Correct 179 ms 141036 KB Output is correct
6 Correct 147 ms 131820 KB Output is correct
7 Correct 195 ms 178284 KB Output is correct
8 Correct 236 ms 204924 KB Output is correct
9 Correct 310 ms 228332 KB Output is correct
10 Correct 363 ms 240580 KB Output is correct
11 Correct 307 ms 203116 KB Output is correct
12 Correct 115 ms 122092 KB Output is correct
13 Runtime error 519 ms 262144 KB Execution killed with signal 6 (could be triggered by violating memory limits)
14 Runtime error 512 ms 262144 KB Execution killed with signal 6 (could be triggered by violating memory limits)
15 Correct 264 ms 195948 KB Output is correct
16 Correct 244 ms 198380 KB Output is correct
17 Correct 204 ms 141420 KB Output is correct
18 Correct 124 ms 123756 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 229 ms 131564 KB Output is correct
2 Correct 257 ms 136812 KB Output is correct
3 Runtime error 526 ms 262144 KB Execution killed with signal 6 (could be triggered by violating memory limits)
4 Correct 306 ms 156288 KB Output is correct
5 Correct 733 ms 229100 KB Output is correct
6 Correct 225 ms 173932 KB Output is correct
7 Correct 225 ms 131564 KB Output is correct
8 Correct 285 ms 152044 KB Output is correct
9 Correct 927 ms 246008 KB Output is correct
10 Runtime error 548 ms 262144 KB Execution killed with signal 6 (could be triggered by violating memory limits)
11 Runtime error 548 ms 262144 KB Execution killed with signal 6 (could be triggered by violating memory limits)
12 Correct 450 ms 214784 KB Output is correct
13 Correct 171 ms 138604 KB Output is correct
14 Correct 306 ms 156396 KB Output is correct
15 Runtime error 583 ms 262144 KB Execution killed with signal 6 (could be triggered by violating memory limits)
16 Correct 257 ms 136812 KB Output is correct
17 Runtime error 553 ms 262144 KB Execution killed with signal 6 (could be triggered by violating memory limits)
18 Correct 910 ms 257440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 539 ms 262144 KB Execution killed with signal 6 (could be triggered by violating memory limits)
2 Runtime error 544 ms 262144 KB Execution killed with signal 6 (could be triggered by violating memory limits)
3 Runtime error 532 ms 262144 KB Execution killed with signal 6 (could be triggered by violating memory limits)
4 Correct 520 ms 224924 KB Output is correct
5 Correct 375 ms 137068 KB Output is correct
6 Runtime error 711 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
7 Correct 730 ms 196204 KB Output is correct
8 Runtime error 539 ms 262144 KB Execution killed with signal 6 (could be triggered by violating memory limits)
9 Runtime error 532 ms 262144 KB Execution killed with signal 6 (could be triggered by violating memory limits)
10 Correct 604 ms 208620 KB Output is correct
11 Correct 479 ms 184684 KB Output is correct
12 Runtime error 677 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
13 Runtime error 576 ms 262144 KB Execution killed with signal 6 (could be triggered by violating memory limits)
14 Correct 431 ms 250640 KB Output is correct
15 Runtime error 525 ms 262144 KB Execution killed with signal 6 (could be triggered by violating memory limits)
16 Runtime error 525 ms 262144 KB Execution killed with signal 6 (could be triggered by violating memory limits)
17 Correct 885 ms 236524 KB Output is correct
18 Runtime error 530 ms 262144 KB Execution killed with signal 6 (could be triggered by violating memory limits)
19 Correct 204 ms 154476 KB Output is correct
20 Runtime error 524 ms 262144 KB Execution killed with signal 6 (could be triggered by violating memory limits)
21 Runtime error 453 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
22 Runtime error 540 ms 262144 KB Execution killed with signal 6 (could be triggered by violating memory limits)
23 Correct 401 ms 140268 KB Output is correct
24 Correct 205 ms 133484 KB Output is correct
25 Correct 597 ms 223440 KB Output is correct
26 Correct 499 ms 224876 KB Output is correct
27 Runtime error 521 ms 262144 KB Execution killed with signal 6 (could be triggered by violating memory limits)
28 Correct 217 ms 149996 KB Output is correct
29 Execution timed out 1110 ms 236732 KB Time limit exceeded
30 Execution timed out 1014 ms 215148 KB Time limit exceeded
31 Correct 304 ms 153964 KB Output is correct
32 Correct 364 ms 165868 KB Output is correct
33 Correct 171 ms 126700 KB Output is correct
34 Correct 735 ms 196332 KB Output is correct
35 Correct 255 ms 151916 KB Output is correct
36 Runtime error 526 ms 262144 KB Execution killed with signal 6 (could be triggered by violating memory limits)
37 Correct 365 ms 137068 KB Output is correct
38 Runtime error 714 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
39 Correct 256 ms 138220 KB Output is correct
40 Correct 712 ms 244076 KB Output is correct
41 Correct 628 ms 217196 KB Output is correct
42 Runtime error 533 ms 262144 KB Execution killed with signal 6 (could be triggered by violating memory limits)