Submission #116322

# Submission time Handle Problem Language Result Execution time Memory
116322 2019-06-12T08:30:24 Z user202729 Ancient Books (IOI17_books) C++17
0 / 100
2 ms 512 KB
#include "books.h"
#include<vector>
#include<cstdlib>
#include<climits>

long long minimum_walk(std::vector<int> p, int s) {
	if(s!=0)return -1;
	std::vector<char> vs(p.size());
	int max_cr=0;
	long long sbookmove=0;
	for(int i=p.size();i--;){
		sbookmove+=std::abs(i-p[i]);

		if(vs[i])continue;
		int cr=INT_MAX; // closest to the right of s
		for(int j=i;;){
			vs[j]=true;
			cr=std::min(cr,j);

			j=p[j];
			if(j==i)break;
		}
		if(p[i]!=i)
			max_cr=std::max(max_cr,cr);
	}
	return sbookmove+2*max_cr;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Incorrect 2 ms 384 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Incorrect 2 ms 384 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Incorrect 2 ms 384 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB 3rd lines differ - on the 1st token, expected: '3304', found: '-1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Incorrect 2 ms 384 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
7 Halted 0 ms 0 KB -