#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 = 200'000;
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;
}
Compilation message
/tmp/ccax8ehm.o: in function `__tcf_0':
plants.cpp:(.text+0x9): relocation truncated to fit: R_X86_64_PC32 against symbol `adj' defined in .bss section in /tmp/ccax8ehm.o
/tmp/ccax8ehm.o: in function `__tcf_1':
plants.cpp:(.text+0x59): relocation truncated to fit: R_X86_64_PC32 against symbol `rev' defined in .bss section in /tmp/ccax8ehm.o
/tmp/ccax8ehm.o: in function `dp(int)':
plants.cpp:(.text+0xb9): relocation truncated to fit: R_X86_64_PC32 against symbol `vis' defined in .bss section in /tmp/ccax8ehm.o
plants.cpp:(.text+0x105): relocation truncated to fit: R_X86_64_PC32 against symbol `adj' defined in .bss section in /tmp/ccax8ehm.o
/tmp/ccax8ehm.o: in function `compare_plants(int, int)':
plants.cpp:(.text+0x18a): relocation truncated to fit: R_X86_64_PC32 against symbol `vis' defined in .bss section in /tmp/ccax8ehm.o
/tmp/ccax8ehm.o: in function `owo(std::vector<int, std::allocator<int> >*, int)':
plants.cpp:(.text+0x268): relocation truncated to fit: R_X86_64_PC32 against symbol `vis' defined in .bss section in /tmp/ccax8ehm.o
plants.cpp:(.text+0x2a3): relocation truncated to fit: R_X86_64_PC32 against symbol `vis' defined in .bss section in /tmp/ccax8ehm.o
/tmp/ccax8ehm.o: in function `init(int, std::vector<int, std::allocator<int> >)':
plants.cpp:(.text+0x56b): relocation truncated to fit: R_X86_64_PC32 against symbol `adj' defined in .bss section in /tmp/ccax8ehm.o
plants.cpp:(.text+0x621): relocation truncated to fit: R_X86_64_PC32 against symbol `rev' defined in .bss section in /tmp/ccax8ehm.o
plants.cpp:(.text+0x71f): relocation truncated to fit: R_X86_64_PC32 against symbol `adj' defined in .bss section in /tmp/ccax8ehm.o
plants.cpp:(.text+0x730): additional relocation overflows omitted from the output
/usr/bin/ld: failed to convert GOTPCREL relocation; relink with --no-relax
collect2: error: ld returned 1 exit status