#include "plants.h"
#ifdef NYAOWO
#include "grader.cpp"
#endif
#include <bits/stdc++.h>
#define For(i, a, b) for(int i = a; i <= b; i++)
#define Forr(i, a, b) for(int i = a; i >= b; i--)
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sz(x) ((int)x.size())
#define eb emplace_back
// #define int LL
using namespace std;
using i32 = int32_t;
using LL = long long;
using pii = pair<int, int>;
const int MAXN = 300;
vector<int> adj[MAXN + 10];
vector<int> rev[MAXN + 10];
int vis[MAXN + 10];
bitset<MAXN + 10> tal[MAXN + 10];
int dist(int s, int t, int n) {
if(s <= t) return t - s;
else return t - s + n;
}
void dp(int n) {
if(vis[n]) return;
vis[n] = 1;
tal[n].reset();
for(auto &i:adj[n]) {
dp(i);
tal[n] |= tal[i];
tal[n][i] = 1;
}
}
void owo(vector<int> *ad, int tag) {
queue<int> que;
que.emplace(0);
vis[0] |= tag;
while(!que.empty()) {
int cur = que.front(); que.pop();
for(auto &i:ad[cur]) if((vis[i] & tag) == 0) {
que.emplace(i);
vis[i] |= tag;
}
}
}
void init(int k, vector<int> r) {
int n = sz(r);
vector<int> alive(n, 1);
int cnt = n;
while(cnt > 0) {
int idx = -1, last = -1;
For(_, 0, 1) For(i, 0, n - 1) if(alive[i] && r[i] == 0) {
if(idx < 0 || dist(last, i, n) >= k) idx = i;
last = i;
}
// cerr << idx << "\n";
// For(i, 0, n - 1) cerr << r[i] << " \n"[i == n - 1];
For(i, n - k + 1, n - 1) {
int le = (idx + i) % n;
if(alive[le]) {
r[le]--;
adj[le].eb(idx);
rev[idx].eb(le);
} else {
adj[idx].eb(le);
rev[le].eb(idx);
}
}
alive[idx] = 0;
cnt--;
}
// memset(vis, 0, sizeof(vis));
// For(i, 0, n - 1) dp(i);
owo(adj, 1);
owo(rev, 2);
}
int compare_plants(int x, int y) {
if(vis[y] & 1) return -1;
if(vis[y] & 2) return 1;
return 0;
// if(tal[y][x]) return 1;
// if(tal[x][y]) return -1;
// return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
216 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |