답안 #51509

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
51509 2018-06-18T04:49:52 Z aome 고대 책들 (IOI17_books) C++17
50 / 100
224 ms 20616 KB
#include <bits/stdc++.h>
#include "books.h"

using namespace std;

const int N = 1000005;

bool visit[N];

long long minimum_walk(vector<int> p, int s) {
	assert(s == 0);
	int n = p.size();
	int cur = 0;
	long long sum = 0;
	int lim = 0;
	for (int i = 0; i < n; ++i) {
		sum += abs(p[i] - i);
		visit[i] = 0;
		if (i != p[i]) lim = i;
	}
	while (1) {
		queue<int> qu;
		visit[cur] = 1, qu.push(cur);

		while (qu.size()) {
			int u = qu.front(); qu.pop();
			while (cur < p[u]) {
				cur++, visit[cur] = 1, qu.push(cur);
			}
		}

		if (cur == lim) break;
		sum += 2, cur++;
	}
	return sum;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 468 KB Output is correct
3 Correct 2 ms 468 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 2 ms 468 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 3 ms 468 KB Output is correct
8 Correct 2 ms 516 KB Output is correct
9 Correct 2 ms 580 KB Output is correct
10 Correct 3 ms 740 KB Output is correct
11 Correct 2 ms 776 KB Output is correct
12 Correct 2 ms 792 KB Output is correct
13 Correct 2 ms 792 KB Output is correct
14 Correct 3 ms 792 KB Output is correct
15 Correct 2 ms 792 KB Output is correct
16 Correct 2 ms 792 KB Output is correct
17 Correct 2 ms 792 KB Output is correct
18 Correct 2 ms 792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 468 KB Output is correct
3 Correct 2 ms 468 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 2 ms 468 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 3 ms 468 KB Output is correct
8 Correct 2 ms 516 KB Output is correct
9 Correct 2 ms 580 KB Output is correct
10 Correct 3 ms 740 KB Output is correct
11 Correct 2 ms 776 KB Output is correct
12 Correct 2 ms 792 KB Output is correct
13 Correct 2 ms 792 KB Output is correct
14 Correct 3 ms 792 KB Output is correct
15 Correct 2 ms 792 KB Output is correct
16 Correct 2 ms 792 KB Output is correct
17 Correct 2 ms 792 KB Output is correct
18 Correct 2 ms 792 KB Output is correct
19 Correct 3 ms 792 KB Output is correct
20 Correct 2 ms 792 KB Output is correct
21 Correct 2 ms 864 KB Output is correct
22 Correct 3 ms 864 KB Output is correct
23 Correct 2 ms 864 KB Output is correct
24 Correct 2 ms 864 KB Output is correct
25 Correct 3 ms 864 KB Output is correct
26 Correct 2 ms 864 KB Output is correct
27 Correct 2 ms 864 KB Output is correct
28 Correct 2 ms 864 KB Output is correct
29 Correct 2 ms 864 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 468 KB Output is correct
3 Correct 2 ms 468 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 2 ms 468 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 3 ms 468 KB Output is correct
8 Correct 2 ms 516 KB Output is correct
9 Correct 2 ms 580 KB Output is correct
10 Correct 3 ms 740 KB Output is correct
11 Correct 2 ms 776 KB Output is correct
12 Correct 2 ms 792 KB Output is correct
13 Correct 2 ms 792 KB Output is correct
14 Correct 3 ms 792 KB Output is correct
15 Correct 2 ms 792 KB Output is correct
16 Correct 2 ms 792 KB Output is correct
17 Correct 2 ms 792 KB Output is correct
18 Correct 2 ms 792 KB Output is correct
19 Correct 3 ms 792 KB Output is correct
20 Correct 2 ms 792 KB Output is correct
21 Correct 2 ms 864 KB Output is correct
22 Correct 3 ms 864 KB Output is correct
23 Correct 2 ms 864 KB Output is correct
24 Correct 2 ms 864 KB Output is correct
25 Correct 3 ms 864 KB Output is correct
26 Correct 2 ms 864 KB Output is correct
27 Correct 2 ms 864 KB Output is correct
28 Correct 2 ms 864 KB Output is correct
29 Correct 2 ms 864 KB Output is correct
30 Correct 176 ms 20616 KB Output is correct
31 Correct 164 ms 20616 KB Output is correct
32 Correct 159 ms 20616 KB Output is correct
33 Correct 192 ms 20616 KB Output is correct
34 Correct 196 ms 20616 KB Output is correct
35 Correct 224 ms 20616 KB Output is correct
36 Correct 165 ms 20616 KB Output is correct
37 Correct 207 ms 20616 KB Output is correct
38 Correct 192 ms 20616 KB Output is correct
39 Correct 154 ms 20616 KB Output is correct
40 Correct 164 ms 20616 KB Output is correct
41 Correct 161 ms 20616 KB Output is correct
42 Correct 159 ms 20616 KB Output is correct
43 Correct 148 ms 20616 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 20616 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 468 KB Output is correct
3 Correct 2 ms 468 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 2 ms 468 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 3 ms 468 KB Output is correct
8 Correct 2 ms 516 KB Output is correct
9 Correct 2 ms 580 KB Output is correct
10 Correct 3 ms 740 KB Output is correct
11 Correct 2 ms 776 KB Output is correct
12 Correct 2 ms 792 KB Output is correct
13 Correct 2 ms 792 KB Output is correct
14 Correct 3 ms 792 KB Output is correct
15 Correct 2 ms 792 KB Output is correct
16 Correct 2 ms 792 KB Output is correct
17 Correct 2 ms 792 KB Output is correct
18 Correct 2 ms 792 KB Output is correct
19 Correct 3 ms 792 KB Output is correct
20 Correct 2 ms 792 KB Output is correct
21 Correct 2 ms 864 KB Output is correct
22 Correct 3 ms 864 KB Output is correct
23 Correct 2 ms 864 KB Output is correct
24 Correct 2 ms 864 KB Output is correct
25 Correct 3 ms 864 KB Output is correct
26 Correct 2 ms 864 KB Output is correct
27 Correct 2 ms 864 KB Output is correct
28 Correct 2 ms 864 KB Output is correct
29 Correct 2 ms 864 KB Output is correct
30 Correct 176 ms 20616 KB Output is correct
31 Correct 164 ms 20616 KB Output is correct
32 Correct 159 ms 20616 KB Output is correct
33 Correct 192 ms 20616 KB Output is correct
34 Correct 196 ms 20616 KB Output is correct
35 Correct 224 ms 20616 KB Output is correct
36 Correct 165 ms 20616 KB Output is correct
37 Correct 207 ms 20616 KB Output is correct
38 Correct 192 ms 20616 KB Output is correct
39 Correct 154 ms 20616 KB Output is correct
40 Correct 164 ms 20616 KB Output is correct
41 Correct 161 ms 20616 KB Output is correct
42 Correct 159 ms 20616 KB Output is correct
43 Correct 148 ms 20616 KB Output is correct
44 Runtime error 3 ms 20616 KB Execution killed with signal 11 (could be triggered by violating memory limits)
45 Halted 0 ms 0 KB -