답안 #1028886

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1028886 2024-07-20T09:59:58 Z DorostWef 고대 책들 (IOI17_books) C++17
0 / 100
1 ms 344 KB
#include "books.h"
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

const int N = 100012;
bool vis[N];
int n;

long long minimum_walk(std::vector<int> p, int s) {
	long long ans = 0;
	n = (int)p.size();
	for (int i = 0; i < n; i++) {
		ans += abs (p[i] - i);
	}
	int mx = 0;
	for (int i = 0; i < n; i++) {
		if (!vis[i]) {
			mx = i;
			int j = i;
			while (p[j] != i) {
				j = p[j];
				vis[j] = true;
			}
		}
	}
	return ans + 2 * mx;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 1 ms 344 KB 3rd lines differ - on the 1st token, expected: '6', found: '8'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 1 ms 344 KB 3rd lines differ - on the 1st token, expected: '6', found: '8'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 1 ms 344 KB 3rd lines differ - on the 1st token, expected: '6', found: '8'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB 3rd lines differ - on the 1st token, expected: '3304', found: '4736'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 1 ms 344 KB 3rd lines differ - on the 1st token, expected: '6', found: '8'
3 Halted 0 ms 0 KB -