답안 #804469

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
804469 2023-08-03T08:54:58 Z Benmath 고대 책들 (IOI17_books) C++14
0 / 100
1 ms 212 KB
#include "books.h"

#include <bits/stdc++.h>

using namespace std;
long long minimum_walk(std::vector<int> p, int s) {
	long long int sum=0;
	int n=p.size();
	int vis[n];
	for(int i=0;i<n;i++){
	    vis[i]=0;
	}
long long	int sad=0;
	for(int i=0;i<n;i++){
	    if(vis[i]==0 and i!=p[i]){
	        sad=i;
	        int i1=i;
	        int t1=0;
	        long long int iduci=p[i];
	        long long int tren=i;
	        while(t1==0){
	            sum=sum+abs(iduci-tren);
	            vis[tren]++;
	            tren=iduci;
	            iduci=p[tren];
	            if(tren==i1){
	                break;
	            }
	        }
	    }
	}
	sum=sum+2*sad;
	return sum;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 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 212 KB Output is correct
6 Incorrect 1 ms 212 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
7 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 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Incorrect 1 ms 212 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
7 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 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Incorrect 1 ms 212 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB 3rd lines differ - on the 1st token, expected: '3304', found: '4728'
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 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Incorrect 1 ms 212 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
7 Halted 0 ms 0 KB -