#include <bits/stdc++.h>
#define fi first
#define se second
#define hkoi
#ifndef hkoi
#include "train.h"
#endif
using namespace std;
const int N = 5001, M = 20001;
int n, m;
vector<int> G[N], H[N];
std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) {
::n = a.size(), ::m = u.size();
std::vector<int> losed(n, 0), charged(n, 0), ans(n, 0), cnt(n, 0);
std::vector<bool> self(n, 0);
for(int i = 0; i < n; i++){
G[i].clear(); H[i].clear();
}
for(int i = 0; i < m; i++){
G[u[i]].push_back(v[i]);
H[v[i]].push_back(u[i]);
if(u[i] == v[i])
self[u[i]] = true;
}
priority_queue<pair<int, int>> pq;
set<pair<int, int>> used;
set<int> rch; for(int i = 0; i < n; i++) if(r[i]) rch.insert(i);
for(int j = 0; j < n; j++){
if(r[j] == 1){
charged[j] = true;
for(auto k : H[j]){
used.insert({k, j});
cnt[k]++; pq.push({(a[k] << 16) + cnt[k], k});
}
}
}
while(pq.size()){
pair<int, int> t = pq.top(); pq.pop();
int v = t.se;
if(t.fi >= G[v].size()) {
charged[v] = true;
for(auto k : H[v]){
if(used.count({k, v})) continue;
used.insert({k, v});
cnt[k]++; pq.push({(a[k] << 16) + cnt[k], k});
}
}
}
used.clear();
fill(cnt.begin(), cnt.end(), 0);
for(int j = 0; j < n; j++){
if(!charged[j]){
losed[j] = true;
for(auto k : H[j]){
used.insert({k, j});
cnt[k]++; pq.push({((!a[k]) << 16) + cnt[k], k});
}
}
}
while(pq.size()){
pair<int, int> t = pq.top(); pq.pop();
int v = t.se;
if(t.fi >= G[v].size() - (rch.find(v) == rch.end() && self[v])) {
losed[v] = true;
for(auto k : H[v]){
if(used.count({k, v})) continue;
used.insert({k, v});
cnt[k]++; pq.push({((!a[k]) << 16) + cnt[k], k});
}
}
}
for(int u = 0; u < n; u++){
ans[u] = !losed[u];
}
return ans;
}
#ifdef hkoi
int main(){
int n, m; cin >> n >> m;
vector<int> a; for(int i = 0; i < n; i++) {
int v; cin >> v; a.push_back(v);
}
vector<int> r; for(int i = 0; i < n; i++) {
int v; cin >> v; r.push_back(v);
}
vector<int> u, v; for(int i = 0; i < m; i++){
int x, y; cin >> x >> y;
u.push_back(x); v.push_back(y);
}
vector<int> w = who_wins(a, r, u, v);
for(int i = 0; i < n; i++){
cout << w[i] << ' ';
}
cout << '\n';
}
#endif
Compilation message
train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:45:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
45 | if(t.fi >= G[v].size()) {
| ~~~~~^~~~~~~~~~~~~~
train.cpp:70:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
70 | if(t.fi >= G[v].size() - (rch.find(v) == rch.end() && self[v])) {
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccAByzMR.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccCIFE5S.o:train.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status