Submission #203791

#TimeUsernameProblemLanguageResultExecution timeMemory
203791anonymousToy Train (IOI17_train)C++14
0 / 100
12 ms1528 KiB
#include "train.h" #include<vector> #include<iostream> #define MAXN 1005 using namespace std; int V,E; bool can1[MAXN], can2[MAXN]; //uncharged forced path, forced path vector <int> adj[MAXN]; vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) { vector<int> res; V = a.size(), E=u.size(); for (int i=0; i<E; i++) { adj[u[i]].push_back(v[i]); } for (int S=0; S<V; S++) { for (int e=0; e<E; e++) { if (r[u[e]] || r[v[e]] || a[u[e]]) {continue;} for (int i=0; i<V; i++) { can1[i] = can2[i] = 0; } can1[u[e]] = true, can2[v[e]] = true; for (int i=0; i<V; i++) { //phase for (int cur=0; cur<V; cur++) { //each node if (a[cur]) { //charged guy bool all1 = 1, all2 = 1; for (auto to: adj[cur]) { if (!can1[to]) {all1=false;} if (!can2[to]) {all2=false;} } if (!r[cur] && all1) {can1[cur]=true;} if (all2) {can2[cur]=true;} } else { bool has1 = 0, has2 = 0; for (auto to: adj[cur]) { if (can1[to]) {has1=true;} if (can2[to]) {has2=true;} } if (!r[cur] && has1) {can1[cur]=true;} if (has2) {can2[cur]=true;} } } } if (can2[S] && can1[v[e]]) { res.push_back(0); break; } } if (res.size() == S) { res.push_back(1); } } 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:50:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (res.size() == S) {
             ~~~~~~~~~~~^~~~
#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...