답안 #619639

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
619639 2022-08-02T13:55:37 Z AriaH 식물 비교 (IOI20_plants) C++17
5 / 100
88 ms 7912 KB
#include "plants.h"
/* I can do this all day */

#pragma GCC optimize("O3")

#include <bits/stdc++.h>

using namespace std;

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

#define F first
#define S second
#define all(x) x.begin(),x.end()
#define Mp make_pair
#define point complex
#define endl '\n'
#define SZ(x) (int)x.size()
#define fast_io ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define file_io freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);

const int N = 1e6 + 10;
const int LOG = 20;
const ll mod = 1e9 + 7;
const ll inf = 8e18;
const double pi = acos(-1);
const ld eps = 1e-18;
const ld one = 1.;

ll pw(ll a, ll b, ll M, ll ret = 1) { if(a == 0) return 0; a %= M; while(b) { ret = (b & 1? ret * a % M : ret), a = a * a % M, b >>= 1; } return ret % M; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, ps[N];

void init(int k, vector < int > r)
{
	n = SZ(r);
	for(int i = 1; i <= n; i ++)
	{
		ps[i] = ps[i - 1] + (1 - r[i - 1]);
		///printf("i = %d ps = %d\n", i, ps[i]);
	}
	return;
}

int compare_plants(int x, int y)
{
	int z = 1;
	x ++;
	y ++;
	if(x > y)
	{
		swap(x, y);
		z = -1;
	}
	if(ps[y - 1] - ps[x - 1] == 0)
	{
		return -1 * z;
	}
	if(ps[y - 1] - ps[x - 1] == y - x)
	{
		return 1 * z;
	}
	if(ps[n] - ps[y - 1] + ps[x - 1] == 0)
	{
		return 1 * z;
	}
	if(ps[n] - ps[y - 1] + ps[x - 1] == n - y + x)
	{
		return -1 * z;
	}
	/*printf("n = %d x = %d y = %d\n",n,  x, y);
	printf("x = %d y = %d n - y + x = %d\n", x, y, n - y + x);
	*/
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 312 KB Output is correct
5 Correct 0 ms 316 KB Output is correct
6 Correct 62 ms 4040 KB Output is correct
7 Correct 53 ms 5424 KB Output is correct
8 Correct 83 ms 7904 KB Output is correct
9 Correct 78 ms 7908 KB Output is correct
10 Correct 88 ms 7880 KB Output is correct
11 Correct 79 ms 7896 KB Output is correct
12 Correct 85 ms 7912 KB Output is correct
13 Correct 79 ms 7904 KB Output is correct
14 Correct 70 ms 7888 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 0 ms 212 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 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 320 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 1 ms 316 KB Output isn't correct
5 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 Correct 1 ms 212 KB Output is correct
4 Incorrect 0 ms 316 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 312 KB Output is correct
5 Correct 0 ms 316 KB Output is correct
6 Correct 62 ms 4040 KB Output is correct
7 Correct 53 ms 5424 KB Output is correct
8 Correct 83 ms 7904 KB Output is correct
9 Correct 78 ms 7908 KB Output is correct
10 Correct 88 ms 7880 KB Output is correct
11 Correct 79 ms 7896 KB Output is correct
12 Correct 85 ms 7912 KB Output is correct
13 Correct 79 ms 7904 KB Output is correct
14 Correct 70 ms 7888 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Incorrect 0 ms 212 KB Output isn't correct
18 Halted 0 ms 0 KB -