Submission #66506

# Submission time Handle Problem Language Result Execution time Memory
66506 2018-08-11T07:09:01 Z Bruteforceman popa (BOI18_popa) C++11
100 / 100
128 ms 664 KB
#include <bits/stdc++.h>
#include "popa.h"
using namespace std;
int par[1111];

int solve(int N, int* left, int* right) {
	int cur = 0;
	int root = 0;
	memset(par, -1, sizeof par);
	for(int i = 0; i < N; i++) {
		right[i] = -1;
		left[i] = -1;
	}
	for(int i = 1; i < N; i++) {
		while(cur != -1) {
			if(query(cur, i, cur, cur) == true) {
				if(right[cur] != -1){
					left[i] = right[cur];
					par[right[cur]] = i; 
				}
				right[cur] = i;
				par[i] = cur;
				// cout << "set parent " << i << " " << cur << endl;
				break;
			}
			cur = par[cur];
		}
		if(cur == -1) {
			par[root] = i;
			left[i] = root;
			root = i;
			// cout << "set parent " << i << " " << -1 << endl;
		}
		cur = i;
	}	
	return root;
}
# Verdict Execution time Memory Grader output
1 Correct 14 ms 248 KB Output is correct
2 Correct 6 ms 308 KB Output is correct
3 Correct 8 ms 384 KB Output is correct
4 Correct 8 ms 440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 90 ms 440 KB Output is correct
2 Correct 95 ms 596 KB Output is correct
3 Correct 62 ms 596 KB Output is correct
4 Correct 107 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 106 ms 596 KB Output is correct
2 Correct 128 ms 596 KB Output is correct
3 Correct 120 ms 664 KB Output is correct
4 Correct 97 ms 664 KB Output is correct