답안 #823222

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
823222 2023-08-12T09:37:27 Z fatemetmhr 식물 비교 (IOI20_plants) C++17
5 / 100
64 ms 7904 KB
// vaghan ide i nadaram chi benevisam dige :/


#include "plants.h"
#include <bits/stdc++.h>

using namespace std;

#define all(x) x.begin(), x.end()
#define fi     first
#define se     second
#define mp     make_pair
#define pb     push_back

typedef long long ll;

const int maxn5 = 2e5 + 10;

int n, ps[maxn5];

int get_sum(int l, int r){
	if(l < r)
		return ps[r - 1] - (l ? ps[l - 1] : 0);
	return (r ? ps[r - 1] : 0) + ps[n - 1] - ps[l - 1];
}

void init(int k, vector<int> r) {
	n = r.size();
	ps[0] = r[0];
	for(int i = 1; i < n; i++)
		ps[i] = r[i] + ps[i - 1];
	return;
}

int compare_plants(int x, int y) {
	int sum = get_sum(x, y);
	if(sum == 0)
		return 1;
	if(sum == (y - x + n) % n)
		return -1;
	sum = get_sum(y, x);
	if(sum == 0)
		return -1;
	if(sum == (x - y + n) % n)
		return 1;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 312 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
6 Correct 51 ms 4044 KB Output is correct
7 Correct 50 ms 5492 KB Output is correct
8 Correct 57 ms 7868 KB Output is correct
9 Correct 59 ms 7900 KB Output is correct
10 Correct 64 ms 7888 KB Output is correct
11 Correct 57 ms 7884 KB Output is correct
12 Correct 58 ms 7880 KB Output is correct
13 Correct 56 ms 7904 KB Output is correct
14 Correct 63 ms 7884 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 1 ms 312 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 1 ms 312 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 1 ms 312 KB Output is correct
2 Correct 0 ms 308 KB Output is correct
3 Correct 1 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 312 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 312 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
6 Correct 51 ms 4044 KB Output is correct
7 Correct 50 ms 5492 KB Output is correct
8 Correct 57 ms 7868 KB Output is correct
9 Correct 59 ms 7900 KB Output is correct
10 Correct 64 ms 7888 KB Output is correct
11 Correct 57 ms 7884 KB Output is correct
12 Correct 58 ms 7880 KB Output is correct
13 Correct 56 ms 7904 KB Output is correct
14 Correct 63 ms 7884 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Incorrect 1 ms 312 KB Output isn't correct
18 Halted 0 ms 0 KB -