Submission #823269

#TimeUsernameProblemLanguageResultExecution timeMemory
823269NothingXD식물 비교 (IOI20_plants)C++17
0 / 100
4043 ms24276 KiB
#include "plants.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

void debug_out(){cerr<<endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T){
	cerr << H << ' ';
	debug_out(T...);
}

#define debug(...) cerr << "(" << #__VA_ARGS__ << "): ", debug_out(__VA_ARGS__)
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define MP(x, y) make_pair(x, y)

const int maxn = 4e5 + 10;

int n, k, a[maxn], l[maxn], r[maxn];

void init(int _k, std::vector<int> R) {
	n = R.size();
	k = _k;
	for (int i = 0; i < n; i++){
		a[i] = R[i];
		a[n+i] = a[i];
	}
	l[0] = 0;
	for (int i = 1; i < 2*n; i++){
		if (a[i-1] == 0) l[i] = i;
		else l[i] = l[i-1];
	}
	r[2*n-1] = 2*n-1;
	for (int i = 2*n-2; ~i; i--){
		if (a[i] == 1) r[i] = i;
		else r[i] = r[i+1];
	}
	for (int i = 0; i < 2*n; i++){
		debug(i, l[i], r[i]);
	}
}

int compare_plants(int x, int y) {
	bool flg1;
	if (x < y){
		flg1 = (r[x] >= y || l[x+n] <= y);
	}
	else{
		flg1 = (l[x] <= y || r[x] >= y+n);
	}
	bool flg2;
	if (x > y){
		flg2 = (r[y] >= x || l[y+n] <= x);
	}
	else{
		flg2 = (l[y] <= x || r[y] >= x+n);
	}
	return (flg1? 1: (flg2? -1: 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...