답안 #369789

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
369789 2021-02-22T12:14:58 Z MilosMilutinovic 식물 비교 (IOI20_plants) C++14
5 / 100
103 ms 8756 KB
#include "plants.h"
#include <bits/stdc++.h>
using namespace std;

int n, k;
vector<int> a, sum;

int check1(int x, int y) {
	if((x==0&&sum[y-1]==0)||sum[y-1]==sum[x-1])
		return 1;
	int nxt=sum[n-1]-sum[y-1];
	int prv=(x==0?0:sum[x-1]);
	if(nxt==n-y&&prv==x)
		return 1;
	if((x==0&&sum[y-1]==y)||sum[y-1]-sum[x-1]==y-x)
		return -1;
	nxt=sum[n-1]-sum[y-1];
	prv=(x==0?0:sum[x-1]);
	if(nxt==0&&prv==0)
		return -1;
	return 0;
}

int compare_plants(int x, int y) {
	if(k==2)
		return check1(x,y);
//	if(k*2>n)
//		return check2(x,y);
}

void init(int K, vector<int> r) {
	n=(int)r.size(), k=K, a=r, sum=a, partial_sum(sum.begin(), sum.end(), sum.begin());
}

Compilation message

plants.cpp: In function 'int compare_plants(int, int)':
plants.cpp:29:1: warning: control reaches end of non-void function [-Wreturn-type]
   29 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 316 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 87 ms 4128 KB Output is correct
7 Correct 102 ms 5612 KB Output is correct
8 Correct 97 ms 8684 KB Output is correct
9 Correct 98 ms 8756 KB Output is correct
10 Correct 103 ms 8756 KB Output is correct
11 Correct 92 ms 8684 KB Output is correct
12 Correct 94 ms 8684 KB Output is correct
13 Correct 87 ms 8684 KB Output is correct
14 Correct 88 ms 8684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Incorrect 1 ms 364 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Incorrect 1 ms 364 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 512 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Incorrect 1 ms 364 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Incorrect 1 ms 364 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 316 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 87 ms 4128 KB Output is correct
7 Correct 102 ms 5612 KB Output is correct
8 Correct 97 ms 8684 KB Output is correct
9 Correct 98 ms 8756 KB Output is correct
10 Correct 103 ms 8756 KB Output is correct
11 Correct 92 ms 8684 KB Output is correct
12 Correct 94 ms 8684 KB Output is correct
13 Correct 87 ms 8684 KB Output is correct
14 Correct 88 ms 8684 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Incorrect 1 ms 364 KB Output isn't correct
18 Halted 0 ms 0 KB -