답안 #768989

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
768989 2023-06-29T04:12:12 Z ono_de206 식물 비교 (IOI20_plants) C++14
5 / 100
63 ms 10556 KB
#include "plants.h"
#include<bits/stdc++.h>
using namespace std;

#define in insert
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// #define int long long
 
typedef long long ll;
typedef vector<int> vi;
typedef set<int> si;
typedef multiset<int> msi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

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

void init(int _k, vector<int> r) {
	k = _k;
	n = r.size();
	pre.resize(n * 3);
	for(int i = 0; i < 3; i++) {
		a.in(a.end(), all(r));
	}
	pre[0] = a[0];
	for(int i = 0; i + 1 < n * 3; i++) {
		pre[i + 1] = pre[i] + a[i + 1];
	}
}

int compare_plants(int x, int y) {
	if(x < y) {
		int sum = pre[y - 1] - (x == 0 ? 0 : pre[x - 1]);
		if(sum == 0) return 1;
		if(sum == y - x) return -1;
		sum = pre[x + n - 1] - pre[y - 1];
		if(sum == 0) return -1;
		if(sum == x + n - y) return 1;
	} else {
		int sum = pre[y + n - 1] - pre[x - 1];
		if(sum == 0) return 1;
		if(sum == y + n - x) return -1;
		sum = pre[x - 1] - (y == 0 ? 0 : pre[y - 1]);
		if(sum == 0) return -1;
		if(sum == x - y) return 1;
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 38 ms 3036 KB Output is correct
7 Correct 43 ms 3728 KB Output is correct
8 Correct 57 ms 10452 KB Output is correct
9 Correct 61 ms 10468 KB Output is correct
10 Correct 57 ms 10460 KB Output is correct
11 Correct 56 ms 10428 KB Output is correct
12 Correct 63 ms 10556 KB Output is correct
13 Correct 53 ms 10456 KB Output is correct
14 Correct 54 ms 10464 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 38 ms 3036 KB Output is correct
7 Correct 43 ms 3728 KB Output is correct
8 Correct 57 ms 10452 KB Output is correct
9 Correct 61 ms 10468 KB Output is correct
10 Correct 57 ms 10460 KB Output is correct
11 Correct 56 ms 10428 KB Output is correct
12 Correct 63 ms 10556 KB Output is correct
13 Correct 53 ms 10456 KB Output is correct
14 Correct 54 ms 10464 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Incorrect 0 ms 212 KB Output isn't correct
18 Halted 0 ms 0 KB -