제출 #303483

#제출 시각아이디문제언어결과실행 시간메모리
303483Utaha식물 비교 (IOI20_plants)C++14
5 / 100
115 ms7432 KiB
#include "plants.h"
#include<bits/stdc++.h>
using namespace std;
const int maxn = 400005;
#define REP(i,n) for(int i=0;i<(n);i++)
#define eb emplace_back
#define pb push_back
#define SZ(a) ((int)a.size())
#define ALL(a) a.begin(),a.end()
const int INF = 0x3f3f3f3f;
int n,k;

int a[maxn];
vector<int> r;
void init(int _k, std::vector<int> _r) {
	k=_k;
	n = _r.size();
	r = _r;
	REP(i,n) r.pb(r[i]);
	int R = SZ(r);

	bool type = 0;
	for(int i=SZ(r)-1;i>=0;i--){
		if(r[i]==type){
			a[i]=R;
		}
		else{
			R=i+1;
			a[i]=R;
			type = r[i];
		}
	}
}


int compare_plants(int x, int y) {
	int flag = 1;
	if(x>y) swap(x,y),flag = -1;
	if(a[x]>=y){
		if(r[x]==1){
			return -flag;
		}
		else return flag;
	}
	if(a[y]>=x+n){
		if(r[y]==1){
			return flag;
		}
		else return -flag;
	}
	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...