Submission #1063542

#TimeUsernameProblemLanguageResultExecution timeMemory
1063542ZicrusToy Train (IOI17_train)C++17
15 / 100
2033 ms43000 KiB
#include <bits/stdc++.h> #include "train.h" using namespace std; typedef long long ll; ll n; vector<int> a, r; vector<vector<ll>> adj; int solve(ll cur, vector<int> vst) { vst[cur] = 1; if (r[cur]) { for (auto &e : vst) { if (e == 1) e = 2; } } int player = a[cur]; for (auto &e : adj[cur]) { if (player == 1 && vst[e] == 2) return 1; if (player == 0 && vst[e] == 1) return 0; } for (auto &e : adj[cur]) { if (vst[e]) continue; int val = solve(e, vst); if (player == val) return val; } return !player; } vector<int> who_wins(vector<int> A, vector<int> R, vector<int> u, vector<int> v) { n = A.size(); a = A; r = R; vector<int> res(n); adj = vector<vector<ll>>(n); for (int i = 0; i < u.size(); i++) { adj[u[i]].push_back(v[i]); } mt19937 mt(75834); for (auto &e : adj) shuffle(e.begin(), e.end(), mt); vector<int> vst(n); for (int i = 0; i < n; i++) { res[i] = solve(i, vst); } 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:36:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     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...