Submission #137379

#TimeUsernameProblemLanguageResultExecution timeMemory
137379MAMBAToy Train (IOI17_train)C++17
11 / 100
13 ms1684 KiB
#include "train.h" #include <bits/stdc++.h> using namespace std; #define rep(i, j, k) for (int i = j; i < (int)k; i++) #define pb push_back #define all(x) x.begin(), x.end() typedef vector<int> vi; vi who_wins(vi a, vi r, vi u, vi v) { int n = a.size(); int m = u.size(); vector<vi> adj(n), radj(n); rep(i, 0, m) { adj[u[i]].pb(v[i]); radj[v[i]].pb(u[i]); } vector<bool> dead(n); int L = 0, R = 0; vi q(n), cnt(n); rep(i, 0, n) if (r[i]) { dead[i] = true; q[R++] = i; } while (L < R) { int me = q[L++]; for (auto e : radj[me]) { if (dead[e]) continue; cnt[e]++; if (a[e] || cnt[e] == adj[e].size()) { dead[e] = true; q[R++] = e; } } } L = R = 0; fill(all(cnt), 0); rep(i, 0, n) for (auto e : adj[i]) if (!dead[e]) cnt[e]++; rep(i, 0, n) if (cnt[i] && (!a[i] || cnt[i] == adj[i].size())) { dead[i] = false; q[R++] = i; } while (L < R) { int me = q[L++]; for (auto e : radj[me]) { if (!dead[e]) continue; cnt[e]++; if (!a[e] || cnt[e] == adj[e].size()) { q[R++] = e; dead[e] = false; } } } vi res(n); rep(i, 0, n) if (dead[i]) res[i] = 1; return res; }

Compilation message (stderr)

train.cpp: In function 'vi who_wins(vi, vi, vi, vi)':
train.cpp:36:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       if (a[e] || cnt[e] == adj[e].size()) {
train.cpp:48:47: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   rep(i, 0, n) if (cnt[i] && (!a[i] || cnt[i] == adj[i].size())) {
train.cpp:58:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       if (!a[e] || cnt[e] == adj[e].size()) {
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...