답안 #424787

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
424787 2021-06-12T10:10:22 Z saleh 고대 책들 (IOI17_books) C++17
0 / 100
1 ms 304 KB
#include "books.h"
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1000 * 1000 + 23;


int mark[MAXN], cnt = 0, ans, jav;

long long minimum_walk(std::vector<int> p, int s) {
	if (s != 0) return 0;
	int n = p.size();
	for (int i = 0; i < n; i++) if (p[i] != i && mark[i] == 0) {
		int tmp = i, pre = i;
		mark[i] = ++cnt;
		while ((tmp = p[tmp]) != i) {
			mark[tmp] = cnt;
			jav += abs(pre - tmp);
			pre = tmp;
		}
		jav += abs(i - pre);
		ans = max(ans, i);
	}
//	cout << jav << ' ' << ans << endl;
	return jav + ans * 2;
}

//int main() {cout << minimum_walk({0, 2, 3, 1}, 0); }
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 304 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Incorrect 0 ms 204 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 304 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Incorrect 0 ms 204 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 304 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Incorrect 0 ms 204 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB 3rd lines differ - on the 1st token, expected: '3304', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 304 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Incorrect 0 ms 204 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
7 Halted 0 ms 0 KB -