답안 #1060443

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1060443 2024-08-15T14:28:10 Z idas 식물 비교 (IOI20_plants) C++17
5 / 100
50 ms 8788 KB
#include "bits/stdc++.h"
#include "plants.h"

#define FOR(i, begin, end) for(int i=(begin); i<(end); i++)
#define sz(x) ((int)(x).size())
#define pb push_back
#define s second
#define f first

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

const int N=2e5+10;
int n, inc[N][2];

void init(int k, std::vector<int> r) {
	n=sz(r);
	for(int i=2*n-1; i>=0; i--) {
		int j=i%n, nxt=inc[(j+1)%n][0];
		if(r[j]==0) {
			if(nxt>0) inc[j][0]=nxt+1;
			else inc[j][0]=1;
		}
		else {
			if(nxt<0) inc[j][0]=nxt-1;
			else inc[j][0]=-1;
		}
	}

	FOR(i, 0, 2*n) {
		int j=i%n, prv=inc[(j-1+n)%n][1];
		if(r[(j-1+n)%n]==0) {
			if(prv<0) inc[j][1]=prv-1;
			else inc[j][1]=-1;
		}
		else {
			if(prv>0) inc[j][1]=prv+1;
			else inc[j][1]=1;
		}
	}
}

int compare_plants(int x, int y) {
	int up=y-x, down=n-up;
	if(inc[x][0]>=up || inc[x][1]>=down) return 1;
	if(-inc[x][0]>=up || -inc[x][1]>=down) return -1;
	return 0;
}
/*
4 1 1
0 1 1 0
1 3
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 440 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 30 ms 4104 KB Output is correct
7 Correct 35 ms 5716 KB Output is correct
8 Correct 50 ms 8788 KB Output is correct
9 Correct 49 ms 8784 KB Output is correct
10 Correct 49 ms 8784 KB Output is correct
11 Correct 49 ms 8784 KB Output is correct
12 Correct 48 ms 8788 KB Output is correct
13 Correct 46 ms 8784 KB Output is correct
14 Correct 47 ms 8768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 604 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 1 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 440 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 30 ms 4104 KB Output is correct
7 Correct 35 ms 5716 KB Output is correct
8 Correct 50 ms 8788 KB Output is correct
9 Correct 49 ms 8784 KB Output is correct
10 Correct 49 ms 8784 KB Output is correct
11 Correct 49 ms 8784 KB Output is correct
12 Correct 48 ms 8788 KB Output is correct
13 Correct 46 ms 8784 KB Output is correct
14 Correct 47 ms 8768 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Incorrect 0 ms 348 KB Output isn't correct
18 Halted 0 ms 0 KB -