Submission #781218

#TimeUsernameProblemLanguageResultExecution timeMemory
781218GusterGoose27Toy Train (IOI17_train)C++17
11 / 100
8 ms1876 KiB
#include "train.h" #include <bits/stdc++.h> const int MAXN = 5005; using namespace std; vector<int> edges[MAXN]; vector<int> rev[MAXN]; int deg[MAXN]; bool owner[MAXN]; // 0 b, 1 a vector<int> ans; int n, m; void activate(int cur) { if (ans[cur]) return; // r[i] assert(!ans[cur]); ans[cur] = 1; for (int v: rev[cur]) { deg[v]++; if ((deg[v] == 1 && owner[v]) || (deg[v] == edges[v].size() && !owner[v])) activate(v); } } void deactivate(int cur) { assert(ans[cur]); ans[cur] = 0; for (int v: rev[cur]) { deg[v]--; if ((deg[v] == 0 && owner[v]) || (deg[v] == edges[v].size()-1 && !owner[v])) deactivate(v); } } vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) { n = a.size(); m = u.size(); for (int i = 0; i < n; i++) owner[i] = a[i]; for (int i = 0; i < m; i++) { edges[u[i]].push_back(v[i]); rev[v[i]].push_back(u[i]); } ans = vector<int>(n, 0); for (int i = 0; i < n; i++) { if (r[i]) activate(i); } for (int i = 0; i < n; i++) { if (ans[i] && ((deg[i] == 0 && owner[i]) || (deg[i] < edges[i].size() && !owner[i]))) { assert(r[i]); deactivate(i); } } return ans; }

Compilation message (stderr)

train.cpp: In function 'void activate(int)':
train.cpp:20:44: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |   if ((deg[v] == 1 && owner[v]) || (deg[v] == edges[v].size() && !owner[v])) activate(v);
      |                                     ~~~~~~~^~~~~~~~~~~~~~~~~~
train.cpp: In function 'void deactivate(int)':
train.cpp:29:44: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |   if ((deg[v] == 0 && owner[v]) || (deg[v] == edges[v].size()-1 && !owner[v])) deactivate(v);
      |                                     ~~~~~~~^~~~~~~~~~~~~~~~~~~~
train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:46:55: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |   if (ans[i] && ((deg[i] == 0 && owner[i]) || (deg[i] < edges[i].size() && !owner[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...