답안 #427689

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
427689 2021-06-14T18:55:54 Z lakshith_ 식물 비교 (IOI20_plants) C++14
5 / 100
110 ms 7908 KB
#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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 63 ms 4048 KB Output is correct
7 Correct 67 ms 5444 KB Output is correct
8 Correct 92 ms 7876 KB Output is correct
9 Correct 90 ms 7876 KB Output is correct
10 Correct 96 ms 7908 KB Output is correct
11 Correct 89 ms 7876 KB Output is correct
12 Correct 89 ms 7908 KB Output is correct
13 Correct 84 ms 7876 KB Output is correct
14 Correct 110 ms 7876 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 63 ms 4048 KB Output is correct
7 Correct 67 ms 5444 KB Output is correct
8 Correct 92 ms 7876 KB Output is correct
9 Correct 90 ms 7876 KB Output is correct
10 Correct 96 ms 7908 KB Output is correct
11 Correct 89 ms 7876 KB Output is correct
12 Correct 89 ms 7908 KB Output is correct
13 Correct 84 ms 7876 KB Output is correct
14 Correct 110 ms 7876 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Incorrect 1 ms 204 KB Output isn't correct
18 Halted 0 ms 0 KB -