답안 #302431

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
302431 2020-09-18T16:43:08 Z arnold518 식물 비교 (IOI20_plants) C++14
5 / 100
117 ms 5880 KB
#include "plants.h"
#include <bits/stdc++.h>
using namespace std;

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

const int MAXN = 2e5;

int N, K, R[MAXN+10], P[MAXN+10];
vector<int> V;

void init(int _K, vector<int> _R)
{
	K=_K; N=_R.size();
	for(int i=0; i<N; i++) R[i]=_R[i];

	for(int i=0; i<N; i++)
	{
		if(R[i]!=R[(i+1)%N]) P[(i+1)%N]++;
	}
	for(int i=1; i<N; i++) P[i]+=P[i-1];
	return;
}

int compare_plants(int x, int y)
{
	int ans=0;

	if(P[y-1]-P[x]==0)
	{
		if(R[x]) return -1;
		else return 1;
	}
	if((x==0 ? 0 : P[x-1])+P[N-1]-P[y]==0)
	{
		if(R[y]) return 1;
		else return -1;
	}
	return 0;
}

Compilation message

plants.cpp: In function 'int compare_plants(int, int)':
plants.cpp:29:6: warning: unused variable 'ans' [-Wunused-variable]
   29 |  int ans=0;
      |      ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 65 ms 3192 KB Output is correct
7 Correct 82 ms 3448 KB Output is correct
8 Correct 110 ms 5880 KB Output is correct
9 Correct 112 ms 5784 KB Output is correct
10 Correct 111 ms 5752 KB Output is correct
11 Correct 109 ms 5752 KB Output is correct
12 Correct 107 ms 5752 KB Output is correct
13 Correct 117 ms 5824 KB Output is correct
14 Correct 107 ms 5752 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Incorrect 1 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Incorrect 1 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Incorrect 1 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 416 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Incorrect 0 ms 256 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Incorrect 0 ms 256 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 65 ms 3192 KB Output is correct
7 Correct 82 ms 3448 KB Output is correct
8 Correct 110 ms 5880 KB Output is correct
9 Correct 112 ms 5784 KB Output is correct
10 Correct 111 ms 5752 KB Output is correct
11 Correct 109 ms 5752 KB Output is correct
12 Correct 107 ms 5752 KB Output is correct
13 Correct 117 ms 5824 KB Output is correct
14 Correct 107 ms 5752 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 1 ms 256 KB Output is correct
17 Incorrect 1 ms 256 KB Output isn't correct
18 Halted 0 ms 0 KB -