이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "plants.h"
#include <bits/stdc++.h>
using namespace std;
int K;
int nxtChain = 0;
int comp[200042];
int lstPos[200042];
int fstPos[200042];
bool isInc[200042];
vector<int> chainId[200042];
// edge from A to B if v[A] > v[B]
void init(int k, vector<int> r) {
	int n = (int)r.size();
	bool inc = r[0] < r[1];
	isInc[0] = inc;
	for (int i = 0; i < n; i++) {
		//cout << "cur is " << i << '\n';
		int nxt = (i + 1) % n;
		bool cur = (r[i] < r[nxt]);
		if (cur != inc) {
			nxtChain++;
			//cout << "adding chain " << nxtChain << '\n';
			comp[nxtChain] = nxtChain;
			isInc[nxtChain] =  cur;
			fstPos[nxtChain] = i;
		}
		if (nxt == 0 && (int)chainId[0].size() == 1 && isInc[chainId[0][0]] == cur) {
			comp[nxtChain] = chainId[0][0];
			break;
		}
		inc = cur;
		chainId[i].push_back(nxtChain);
		chainId[nxt].push_back(nxtChain);
		lstPos[nxtChain] = nxt;
	}
	return;
}
int compare_plants(int x, int y) {
	for (auto& a: chainId[x]) {
		for (auto& b: chainId[y]) {
			if (comp[a] == comp[b]) {
				/*printf("pos are %d %d\n", x, y);
				printf("comp x %d %d\n", a, comp[a]);
				printf("comp y %d %d\n", b, comp[b]);*/
				if (comp[b] != b) {
					if (fstPos[b] == x && (int)chainId[x].size() > 1)
						return 0;
					if (isInc[comp[b]])
						return 1;
					return -1;
				}
				if (isInc[a])
					return -1;
				return 1;
			}
		}
	}
	return 0;
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |