Submission #61915

# Submission time Handle Problem Language Result Execution time Memory
61915 2018-07-27T05:12:23 Z 김세빈(#1797) popa (BOI18_popa) C++11
100 / 100
108 ms 708 KB
#include "popa.h"

int S[1010], D[1010];

int solve(int n, int* L, int* R)
{
	int i, j, k, s;
	
	s = 0;
	
	for(i=0; i<n; i++){
		L[i] = R[i] = -1;
		D[i] = i;
		
		for(j=s; j; j--){
			if(!query(D[S[j]], i, i, i)) break;
		}
		for(k=j+1; k<s; k++) R[S[k]] = S[k + 1];
		
		if(j + 1 <= s){
			L[i] = S[j + 1];
			D[i] = D[S[j + 1]];
		}
		s = j + 1; S[s] = i;
	}
	
	for(i=1; i<s; i++) R[S[i]] = S[i + 1];
	
	return S[1];
}
# Verdict Execution time Memory Grader output
1 Correct 12 ms 248 KB Output is correct
2 Correct 11 ms 436 KB Output is correct
3 Correct 11 ms 436 KB Output is correct
4 Correct 11 ms 436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 108 ms 708 KB Output is correct
2 Correct 89 ms 708 KB Output is correct
3 Correct 63 ms 708 KB Output is correct
4 Correct 103 ms 708 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 65 ms 708 KB Output is correct
2 Correct 91 ms 708 KB Output is correct
3 Correct 85 ms 708 KB Output is correct
4 Correct 93 ms 708 KB Output is correct