#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 a[N];
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> win(n, 0), charged(n, 0), ans(n, 0), cnt(n, 0);
for(int i = 0; i < m; i++){
G[u[i]].push_back(v[i]);
H[v[i]].push_back(u[i]);
}
fill(win.begin(), win.end(), 0);
fill(cnt.begin(), cnt.end(), 0);
priority_queue<pair<int, int>> pq;
for(int j = 0; j < n; j++){
if(r[j] == 1){
charged[j] = true;
for(auto k : G[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.fi & ((1 << 16) - 1), c = t.se;
if(win[v]) continue;
if(t.fi >= G[v].size()) {
charged[v] = true;
for(auto k : G[v]){
cnt[k]++; pq.push({(a[k] << 16) + cnt[k], k});
}
}
}
for(int u = 0; u < n; u++){
bool exist = false, all = true;
for(auto v : G[u]){
if(charged[v]) exist = true;
if(!charged[v]) all = false;
}
ans[u] = a[u] ? exist : all;
}
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:40:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
40 | if(t.fi >= G[v].size()) {
| ~~~~~^~~~~~~~~~~~~~
train.cpp:38:35: warning: unused variable 'c' [-Wunused-variable]
38 | int v = t.fi & ((1 << 16) - 1), c = t.se;
| ^
/usr/bin/ld: /tmp/ccPmGH7J.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccsawPpJ.o:train.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status