#include "plants.h"
#include <bits/stdc++.h>
using namespace std;
template<class T, class U>
void ckmin(T &a, U b)
{
if (a > b) a = b;
}
template<class T, class U>
void ckmax(T &a, U b)
{
if (a < b) a = b;
}
#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int) (x).size())
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
const int MAXN = 313;
const int INF = 1e9 + 7;
int N, K;
int arr[MAXN];
int pref[2][MAXN];
// vi edge[MAXN];
bitset<MAXN> edge[MAXN];
void init(int k, vi r)
{
N = SZ(r);
K = k; K--;
FOR(i, 0, N)
{
arr[i] = r[i];
arr[i + N] = arr[i];
pref[0][i + 1] = pref[0][i] + (arr[i] == 0);
pref[1][i + 1] = pref[1][i] + (arr[i] == 1);
}
FOR(i, 0, N)
{
FOR(j, 1, K + 1)
{
if (arr[i + j] >= arr[i] + j)
{
edge[(j + i) % N][i] = true;
// cerr << "ADDEDGE " << (j + i) % N << ' ' << i << endl;
}
if (arr[i + j] - j < arr[i])
{
//xj > xi
edge[i][(i + j) % N] = true;
// cerr << "ADDEDGE " << i << ' ' << (j + i) % N << endl;
}
}
}
FOR(k, 0, N)
{
FOR(i, 0, N)
{
FOR(j, 0, N)
{
if (edge[i][k] && edge[k][j])
{
edge[i][j] = true;
}
}
}
}
//find the 0. there can only be one of them. that # is N-1.
//then subtract 1 from its chidlren.
// build(1, 0, N - 1);
// FORD(i, N, 0)
// {
// auto p = query(1, 0, N - 1, 0, N - 1);
// val[p.se] = i;
// update(1, 0, N - 1, p.se, p.se, INF);
// vpi v = getparent(p.se);
// for (pii q : v)
// {
// update(1, 0, N - 1, q.fi, q.se, -1);
// }
// }
// FOR(i, 0, N)
// {
// cerr << val[i] << endl;
// }
}
int compare_plants(int x, int y)
{
if (edge[x][y])
{
return -1;
}
if (edge[y][x])
{
return 1;
}
return 0;
// if (x > y)
// {
// return -compare_plants(y, x);
// }
// if (pref[0][y] - pref[0][x] == y - x)
// {
// return 1;
// }
// if (pref[1][y] - pref[1][x] == y - x)
// {
// return -1;
// }
// if (pref[0][N] - pref[0][y] + pref[0][x] == N - (y - x))
// {
// return -1;
// }
// if (pref[1][N] - pref[1][y] + pref[1][x] == N - (y - x))
// {
// return 1;
// }
// return 0;
//their ranges must overlap??
//if x...y-1 is all 0's then it's -1.
//if x...y-1 is all 1's then it's 1.
//if y...x-1 is all 0's then it's 1.
//if y...x-1 is all 1's then it's -1.
//check if there's a path from x -> y.
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Incorrect |
1 ms |
204 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 |
204 KB |
Output is correct |
3 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Runtime error |
42 ms |
6064 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |