답안 #73433

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
73433 2018-08-28T09:12:36 Z SmsS 고대 책들 (IOI17_books) C++14
50 / 100
252 ms 16492 KB
#include<bits/stdc++.h>
using namespace std;
#define for2(a,b,c) for(int a = b; a < c; a++)
#include "books.h"
#define ll long long
long long minimum_walk(std::vector<int> p, int s) {
//	if(s != 0) return 0;
	ll res = 0;
	int n = p.size();
	for2(i,0,n) res += abs(i-p[i]);
	vector<int> cmp(n,-1);
	vector<int> sz(n,-1);
	int cnt = 0;
	for2(i,0,n) if(cmp[i] == -1){
		int l = min(i,p[i]);
		int r = max(i,p[i]);
		int L = i;
		int R = i;
		while(L != l || R != r){
			while(l < L){
				L--;
				l = min(l,p[L]);
				r = max(r,p[L]);
			}
			while(R < r){
				R++;
				l = min(l,p[R]);
				r = max(r,p[R]);
			}

		}
		for2(i,l,r+1){
			sz[i] = r-l+1;
			cmp[i] = cnt;
		}
		cnt++;
		res += 2;
	}
	res -= 2;
	for(int i = n-1; i > s; i--){
		if(sz[i] != 1) break;
		res -= 2;
	}
	for2(i,0,n){
		if(sz[i] != 1 || i == s) break;
		res -= 2;
	}
	return res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 272 KB Output is correct
2 Correct 4 ms 488 KB Output is correct
3 Correct 3 ms 488 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 2 ms 492 KB Output is correct
6 Correct 2 ms 492 KB Output is correct
7 Correct 2 ms 492 KB Output is correct
8 Correct 2 ms 492 KB Output is correct
9 Correct 3 ms 492 KB Output is correct
10 Correct 2 ms 512 KB Output is correct
11 Correct 2 ms 512 KB Output is correct
12 Correct 2 ms 564 KB Output is correct
13 Correct 2 ms 564 KB Output is correct
14 Correct 2 ms 564 KB Output is correct
15 Correct 3 ms 564 KB Output is correct
16 Correct 2 ms 564 KB Output is correct
17 Correct 3 ms 564 KB Output is correct
18 Correct 2 ms 564 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 272 KB Output is correct
2 Correct 4 ms 488 KB Output is correct
3 Correct 3 ms 488 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 2 ms 492 KB Output is correct
6 Correct 2 ms 492 KB Output is correct
7 Correct 2 ms 492 KB Output is correct
8 Correct 2 ms 492 KB Output is correct
9 Correct 3 ms 492 KB Output is correct
10 Correct 2 ms 512 KB Output is correct
11 Correct 2 ms 512 KB Output is correct
12 Correct 2 ms 564 KB Output is correct
13 Correct 2 ms 564 KB Output is correct
14 Correct 2 ms 564 KB Output is correct
15 Correct 3 ms 564 KB Output is correct
16 Correct 2 ms 564 KB Output is correct
17 Correct 3 ms 564 KB Output is correct
18 Correct 2 ms 564 KB Output is correct
19 Correct 2 ms 580 KB Output is correct
20 Correct 3 ms 580 KB Output is correct
21 Correct 3 ms 580 KB Output is correct
22 Correct 3 ms 580 KB Output is correct
23 Correct 3 ms 580 KB Output is correct
24 Correct 2 ms 580 KB Output is correct
25 Correct 3 ms 700 KB Output is correct
26 Correct 3 ms 700 KB Output is correct
27 Correct 2 ms 700 KB Output is correct
28 Correct 3 ms 700 KB Output is correct
29 Correct 3 ms 700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 272 KB Output is correct
2 Correct 4 ms 488 KB Output is correct
3 Correct 3 ms 488 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 2 ms 492 KB Output is correct
6 Correct 2 ms 492 KB Output is correct
7 Correct 2 ms 492 KB Output is correct
8 Correct 2 ms 492 KB Output is correct
9 Correct 3 ms 492 KB Output is correct
10 Correct 2 ms 512 KB Output is correct
11 Correct 2 ms 512 KB Output is correct
12 Correct 2 ms 564 KB Output is correct
13 Correct 2 ms 564 KB Output is correct
14 Correct 2 ms 564 KB Output is correct
15 Correct 3 ms 564 KB Output is correct
16 Correct 2 ms 564 KB Output is correct
17 Correct 3 ms 564 KB Output is correct
18 Correct 2 ms 564 KB Output is correct
19 Correct 2 ms 580 KB Output is correct
20 Correct 3 ms 580 KB Output is correct
21 Correct 3 ms 580 KB Output is correct
22 Correct 3 ms 580 KB Output is correct
23 Correct 3 ms 580 KB Output is correct
24 Correct 2 ms 580 KB Output is correct
25 Correct 3 ms 700 KB Output is correct
26 Correct 3 ms 700 KB Output is correct
27 Correct 2 ms 700 KB Output is correct
28 Correct 3 ms 700 KB Output is correct
29 Correct 3 ms 700 KB Output is correct
30 Correct 212 ms 16228 KB Output is correct
31 Correct 210 ms 16228 KB Output is correct
32 Correct 190 ms 16236 KB Output is correct
33 Correct 197 ms 16236 KB Output is correct
34 Correct 160 ms 16236 KB Output is correct
35 Correct 225 ms 16236 KB Output is correct
36 Correct 172 ms 16236 KB Output is correct
37 Correct 193 ms 16236 KB Output is correct
38 Correct 192 ms 16284 KB Output is correct
39 Correct 191 ms 16492 KB Output is correct
40 Correct 252 ms 16492 KB Output is correct
41 Correct 179 ms 16492 KB Output is correct
42 Correct 172 ms 16492 KB Output is correct
43 Correct 180 ms 16492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 16492 KB 3rd lines differ - on the 1st token, expected: '3304', found: '2744'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 272 KB Output is correct
2 Correct 4 ms 488 KB Output is correct
3 Correct 3 ms 488 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 2 ms 492 KB Output is correct
6 Correct 2 ms 492 KB Output is correct
7 Correct 2 ms 492 KB Output is correct
8 Correct 2 ms 492 KB Output is correct
9 Correct 3 ms 492 KB Output is correct
10 Correct 2 ms 512 KB Output is correct
11 Correct 2 ms 512 KB Output is correct
12 Correct 2 ms 564 KB Output is correct
13 Correct 2 ms 564 KB Output is correct
14 Correct 2 ms 564 KB Output is correct
15 Correct 3 ms 564 KB Output is correct
16 Correct 2 ms 564 KB Output is correct
17 Correct 3 ms 564 KB Output is correct
18 Correct 2 ms 564 KB Output is correct
19 Correct 2 ms 580 KB Output is correct
20 Correct 3 ms 580 KB Output is correct
21 Correct 3 ms 580 KB Output is correct
22 Correct 3 ms 580 KB Output is correct
23 Correct 3 ms 580 KB Output is correct
24 Correct 2 ms 580 KB Output is correct
25 Correct 3 ms 700 KB Output is correct
26 Correct 3 ms 700 KB Output is correct
27 Correct 2 ms 700 KB Output is correct
28 Correct 3 ms 700 KB Output is correct
29 Correct 3 ms 700 KB Output is correct
30 Correct 212 ms 16228 KB Output is correct
31 Correct 210 ms 16228 KB Output is correct
32 Correct 190 ms 16236 KB Output is correct
33 Correct 197 ms 16236 KB Output is correct
34 Correct 160 ms 16236 KB Output is correct
35 Correct 225 ms 16236 KB Output is correct
36 Correct 172 ms 16236 KB Output is correct
37 Correct 193 ms 16236 KB Output is correct
38 Correct 192 ms 16284 KB Output is correct
39 Correct 191 ms 16492 KB Output is correct
40 Correct 252 ms 16492 KB Output is correct
41 Correct 179 ms 16492 KB Output is correct
42 Correct 172 ms 16492 KB Output is correct
43 Correct 180 ms 16492 KB Output is correct
44 Incorrect 3 ms 16492 KB 3rd lines differ - on the 1st token, expected: '3304', found: '2744'
45 Halted 0 ms 0 KB -