답안 #73399

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
73399 2018-08-28T08:18:45 Z Navick 고대 책들 (IOI17_books) C++17
0 / 100
3 ms 548 KB
#include <bits/stdc++.h>
#include "books.h"

#define F first
#define S second
#define pii pair<int, int>
#define pb push_back

using namespace std;

typedef long long ll;

const int maxN = 1e6 + 10;

bool mark[maxN];

long long minimum_walk(std::vector<int> p, int s) {
	int n = p.size(), m = 0;
	ll ans = 0;

	for (int i=0; i<n; i++)
	{
		if(mark[i]) continue ;
		int curr = i, mn = n, sz = 0;
		while(!mark[curr])
		{
			sz ++;
			mn = min(mn, curr);
			mark[curr] = true;
			ans += abs(p[curr] - curr);
			curr = p[curr];
		}
		if(sz >= 2) m = max(m, mn);
	}
	return ans + 2LL * m;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 468 KB Output is correct
3 Correct 2 ms 472 KB Output is correct
4 Correct 3 ms 472 KB Output is correct
5 Correct 3 ms 480 KB Output is correct
6 Incorrect 2 ms 524 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 468 KB Output is correct
3 Correct 2 ms 472 KB Output is correct
4 Correct 3 ms 472 KB Output is correct
5 Correct 3 ms 480 KB Output is correct
6 Incorrect 2 ms 524 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 468 KB Output is correct
3 Correct 2 ms 472 KB Output is correct
4 Correct 3 ms 472 KB Output is correct
5 Correct 3 ms 480 KB Output is correct
6 Incorrect 2 ms 524 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 548 KB 3rd lines differ - on the 1st token, expected: '3304', found: '4728'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 468 KB Output is correct
3 Correct 2 ms 472 KB Output is correct
4 Correct 3 ms 472 KB Output is correct
5 Correct 3 ms 480 KB Output is correct
6 Incorrect 2 ms 524 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
7 Halted 0 ms 0 KB -