답안 #778229

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
778229 2023-07-10T07:37:06 Z ggoh 고대 책들 (IOI17_books) C++14
0 / 100
1 ms 308 KB
#include "books.h"
#include<bits/stdc++.h>
using namespace std;
#define sz(v) ((int)(v).size())
typedef long long lint;
typedef pair<int,int> pii;

lint minimum_walk(vector<int> p, int s) {
	int n=sz(p);
	lint ans=0;
	vector<int>v(n);
	int m=0,step=0,end=0;
	for(int i=0;i<n;i++)
	{
		if(!v[i])
		{
			int x=i;
			v[i]=1;
			m=i;
			while(p[x]!=i)
			{
				v[p[x]]=1;
				m=max(m,p[x]);
				x=p[x];
			}
			ans+=2*(m-i);
			if(m!=i)
			{
				if(end<i)step+=(i-end);
				if(end<m)end=m;
			}
		}
	}
	ans+=2*step;
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 1 ms 296 KB 3rd lines differ - on the 1st token, expected: '8', found: '6'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 1 ms 296 KB 3rd lines differ - on the 1st token, expected: '8', found: '6'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 1 ms 296 KB 3rd lines differ - on the 1st token, expected: '8', found: '6'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 308 KB 3rd lines differ - on the 1st token, expected: '3304', found: '2720'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 1 ms 296 KB 3rd lines differ - on the 1st token, expected: '8', found: '6'
4 Halted 0 ms 0 KB -