제출 #613995

#제출 시각아이디문제언어결과실행 시간메모리
613995Mounir식물 비교 (IOI20_plants)C++14
0 / 100
0 ms212 KiB
#include "plants.h"
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define chmax(x, v) x = max(x, v)
#define chmin(x, v) x = min(x, v)
#define pb push_back
#define pii pair<int, int>
#define sz(x) (int)x.size()
#define x first
#define y second
using namespace std;

vector<pii> inters;
int nVals;
vector<int> pg;

void init(int k, vector<int> plusGros) {
	nVals = sz(plusGros);
	pg = plusGros;
	for (int i = 0; i < nVals; ++i)
		plusGros.pb(plusGros[i]);
	for (int i = 0; i < nVals; ){
		int pt = i;
		while (pt < nVals && plusGros[pt])
			++pt;
		inters.pb({i, (pt++)%nVals});
		i = pt;
	}
}
 
int compare_plants(int x, int y) {
	if (y == nVals - 1 && x == 0){
		if (pg[y])
			return 1;
		else	
			return -1;
	}
	pii s = {x + 1, 0};
	auto it = lower_bound(all(inters), s);
	--it;
	if (it->y >= y)
		return 1;
	else if (y == x + 1){
		if (pg[x])
			return 1;
		return -1;
	}
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...