Submission #1162000

#TimeUsernameProblemLanguageResultExecution timeMemory
1162000gelastropodpopa (BOI18_popa)C++20
0 / 100
16 ms436 KiB
#include "popa.h"
#include <bits/stdc++.h>
using namespace std;

int solve(int N, int* Left, int* Right) {
	vector<int> p(N, -1);
	for (int i = 0; i < N; i++) {
		Left[i] = -1;
		Right[i] = -1;
	}
	for (int i = 1; i < N; i++) {
		int crnt = i - 1;
		int prev;
		bool allp = false;
		while (query(crnt, i, i, i)) {
			prev = crnt;
			crnt = p[crnt];
			if (crnt == -1) {
				allp = true;
				break;
			}
		}
		if (crnt = i - 1) {
			Right[i - 1] = i;
			p[i] = i - 1;
			continue;
		}
		if (allp) {
			Left[i] = crnt;
			p[crnt] = i;
		}
		else {
			Right[crnt] = i;
			p[i] = crnt;
			Left[i] = prev;
			p[prev] = i;
		}
	}
	for (int i = 0; i < N; i++) {
		if (p[i] == -1) return i;
	}
}

Compilation message (stderr)

popa.cpp: In function 'int solve(int, int*, int*)':
popa.cpp:42:1: warning: control reaches end of non-void function [-Wreturn-type]
   42 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...