제출 #427689

#제출 시각아이디문제언어결과실행 시간메모리
427689lakshith_식물 비교 (IOI20_plants)C++14
5 / 100
110 ms7908 KiB
#include "plants.h"
#include <bits/stdc++.h>

using namespace std;

#define what_is(a) cout << #a  << " is " << a << "\n"

int n;
int pref[200000];

void init(int k, std::vector<int> r) {
	n = r.size();
	pref[0]=r[0];
	for(int i=1;i<n;i++)pref[i]=r[i]+pref[i-1];
	return;
}

int getR(int l,int r){
	return pref[r]-(l==0?0:pref[l-1]);
}

int compare_plants(int x, int y) {
	int b = 1;
	if(x>y){
		swap(x,y);
		b=-1;
	}
	int one=getR(x,y-1),zero=y-x-getR(x,y-1);
	//what_is(one);
	//what_is(zero);
	if(zero==0)return -1*b;
	else if(one==0)return 1*b;
	one = getR(y,n-1)+getR(0,x-1),zero=n-y+x-getR(y,n-1)-getR(0,x-1);
	//what_is(one);
	//what_is(zero);
	if(zero==0)return 1*b;
	else if(one==0)return -1*b;
	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...