답안 #289248

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
289248 2020-09-02T13:40:53 Z eohomegrownapps 고대 책들 (IOI17_books) C++14
0 / 100
1 ms 384 KB
#include "books.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int ptr = 0;
vector<int> cycle;
vector<int> p;
int n;

ll total = 0;

void findcycle(int i){
	total += abs(i-p[i]);
	cycle[i] = ptr;
	if (cycle[p[i]]!=-1){return;}
	findcycle(p[i]);
}

ll minimum_walk(std::vector<int> px, int s) {
	p = px;
	n = p.size();
	cycle.resize(n,-1);
	int minind = -1;
	for (int i = 0; i<n; i++){
		if (cycle[i]!=-1){continue;}
		minind=i;
		findcycle(i);
		ptr++;
	}
	return total+2*minind;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Incorrect 0 ms 256 KB 3rd lines differ - on the 1st token, expected: '6', found: '8'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Incorrect 0 ms 256 KB 3rd lines differ - on the 1st token, expected: '6', found: '8'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Incorrect 0 ms 256 KB 3rd lines differ - on the 1st token, expected: '6', found: '8'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 384 KB 3rd lines differ - on the 1st token, expected: '3304', found: '4736'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Incorrect 0 ms 256 KB 3rd lines differ - on the 1st token, expected: '6', found: '8'
3 Halted 0 ms 0 KB -