Submission #302220

# Submission time Handle Problem Language Result Execution time Memory
302220 2020-09-18T14:28:41 Z TMJN Ancient Books (IOI17_books) C++17
0 / 100
1 ms 512 KB
#include "books.h"
#include <bits/stdc++.h>
using namespace std;

int p,d,h;
vector<int>P;

void movel(int x){
	for(int i=p;i>=x;i--){
		if(h>P[i]){
			swap(h,P[i]);
		}
	}
	d+=p-x;
	p=x;
}

void mover(int x){
	for(int i=p;i<=x;i++){
		if(h<P[i]){
			swap(h,P[i]);
		}
	}
	d+=x-p;
	p=x;
}

long long minimum_walk(vector<int>ppp,int S){
	P=ppp;
	assert(S==0);
	int N=P.size();
	p=0;
	d=0;
	h=P[0];
	h=-1;
	for(int i=N-1;i>0;i--){
		if(P[i]==i)continue;
		for(int j=0;j<N;j++){
			if(P[j]==i){
				if(j<p)movel(j);
				mover(i);
				break;
			}
		}
	}	
	return d+p;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB 3rd lines differ - on the 1st token, expected: '6', found: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB 3rd lines differ - on the 1st token, expected: '6', found: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB 3rd lines differ - on the 1st token, expected: '6', found: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 512 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB 3rd lines differ - on the 1st token, expected: '6', found: '2'
2 Halted 0 ms 0 KB -