답안 #615924

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
615924 2022-07-31T15:07:45 Z MohamedAhmed04 고대 책들 (IOI17_books) C++14
0 / 100
1 ms 308 KB
#include "books.h"
#include <bits/stdc++.h>

using namespace std ;

const int MAX = 1e6 + 10 ;

int mark[MAX] ;

int n ;

long long minimum_walk(std::vector<int> p, int s) 
{
	n = p.size() ; 
	long long ans = 0 , last = 0 ;
	for(int i = 0 ; i < n ; ++i)
	{
		if(mark[i] || i == p[i])
			continue ;
		ans += i - last ;
		last = i ;
		int x = i ;
		while(!mark[x])
		{
			mark[x] = 1 ;
			ans += abs(p[x] - x) ;
			x = p[x] ;
		}
	}
	ans += last ;
	return ans ;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Incorrect 0 ms 212 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Incorrect 0 ms 212 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Incorrect 0 ms 212 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB 3rd lines differ - on the 1st token, expected: '3304', found: '4728'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Incorrect 0 ms 212 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
7 Halted 0 ms 0 KB -