답안 #122970

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
122970 2019-06-29T18:10:56 Z someone_aa 고대 책들 (IOI17_books) C++17
50 / 100
845 ms 31600 KB
#include "books.h"
#include <bits/stdc++.h>
#define ll long long 
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 1000100;
bool suffix[maxn];
int n, loc[maxn];

long long minimum_walk(std::vector<int> p, int s) {
	n = p.size();
	suffix[n] = true;
	for(int i=n-1;i>=0;i--) {
		suffix[i] = suffix[i+1] && (p[i] == i);
		loc[p[i]] = i;
	}

	ll result = 0LL;
	set<int>need;
	for(int i=0;i<n;i++) {
		if(suffix[i+1]) break;

		// if p[i] is in need

		if(need.find(p[i]) != need.end()) need.erase(p[i]);
		if(loc[i] > i) need.insert(i);

		/*cout<<"i: \n";
		for(int i:need) {
			cout<<i<<" ";
		} cout<<"\n";*/

		result += 2LL * max(1, int(need.size()));
	}

	return result;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 256 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 256 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 256 KB Output is correct
19 Correct 3 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 3 ms 376 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 256 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 256 KB Output is correct
19 Correct 3 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 3 ms 376 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 702 ms 24836 KB Output is correct
31 Correct 845 ms 31600 KB Output is correct
32 Correct 143 ms 19704 KB Output is correct
33 Correct 171 ms 19756 KB Output is correct
34 Correct 170 ms 19832 KB Output is correct
35 Correct 172 ms 19880 KB Output is correct
36 Correct 195 ms 19804 KB Output is correct
37 Correct 256 ms 19832 KB Output is correct
38 Correct 291 ms 19832 KB Output is correct
39 Correct 297 ms 19960 KB Output is correct
40 Correct 367 ms 20408 KB Output is correct
41 Correct 531 ms 25848 KB Output is correct
42 Correct 501 ms 24568 KB Output is correct
43 Correct 189 ms 19832 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB 3rd lines differ - on the 1st token, expected: '3304', found: '2744'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 256 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 256 KB Output is correct
19 Correct 3 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 3 ms 376 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 702 ms 24836 KB Output is correct
31 Correct 845 ms 31600 KB Output is correct
32 Correct 143 ms 19704 KB Output is correct
33 Correct 171 ms 19756 KB Output is correct
34 Correct 170 ms 19832 KB Output is correct
35 Correct 172 ms 19880 KB Output is correct
36 Correct 195 ms 19804 KB Output is correct
37 Correct 256 ms 19832 KB Output is correct
38 Correct 291 ms 19832 KB Output is correct
39 Correct 297 ms 19960 KB Output is correct
40 Correct 367 ms 20408 KB Output is correct
41 Correct 531 ms 25848 KB Output is correct
42 Correct 501 ms 24568 KB Output is correct
43 Correct 189 ms 19832 KB Output is correct
44 Incorrect 2 ms 376 KB 3rd lines differ - on the 1st token, expected: '3304', found: '2744'
45 Halted 0 ms 0 KB -