Submission #1063492

#TimeUsernameProblemLanguageResultExecution timeMemory
1063492ZicrusToy Train (IOI17_train)C++17
11 / 100
1347 ms2008 KiB
#include <bits/stdc++.h> #include "train.h" using namespace std; typedef long long ll; ll n; vector<int> a, r, res; vector<vector<ll>> adj, revAdj; vector<bool> vst; bool dfsCyc(ll cur, ll root) { vst[cur] = true; for (auto &e : adj[cur]) { if (e == root) return true; if (vst[e] || r[e]) continue; if (dfsCyc(e, root)) return true; } return false; } void dfsRes(ll cur) { vst[cur] = true; res[cur] = 0; for (auto &e : revAdj[cur]) { if (vst[e]) continue; dfsRes(e); } } vector<int> who_wins(vector<int> A, vector<int> R, vector<int> u, vector<int> v) { n = A.size(); a = A; r = R; res = vector<int>(n, 1); vst = vector<bool>(n); adj = vector<vector<ll>>(n); revAdj = vector<vector<ll>>(n); for (int i = 0; i < u.size(); i++) { adj[u[i]].push_back(v[i]); revAdj[v[i]].push_back(u[i]); } for (int i = 0; i < n; i++) { if (r[i]) continue; vst = vector<bool>(n); if (dfsCyc(i, i)) { vst = vector<bool>(n); dfsRes(i); } } return res; }

Compilation message (stderr)

train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:38:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for (int i = 0; i < u.size(); i++) {
      |                     ~~^~~~~~~~~~
#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...