Submission #116996

#TimeUsernameProblemLanguageResultExecution timeMemory
116996zubecToy Train (IOI17_train)C++14
0 / 100
11 ms1920 KiB
#include "train.h" #include <bits/stdc++.h> using namespace std; vector <int> g[5010], gg[5010]; int kol[5010]; bool used[5010]; int n, clr[5010], chrg[5010]; bool delt[5010]; vector <pair<int, int> > rebr; void cler(){ for (int i = 0; i < n; i++){ used[i] = 0; } for (int i = 0; i < rebr.size(); i++){ int u = rebr[i].first, v = rebr[i].second; if (!delt[u] && !delt[v]) ++kol[u]; } } void f(vector <int> vec, int c){ cler(); while(!vec.empty()){ int v = vec.back(); vec.pop_back(); if (used[v]) continue; used[v] = 1; for (int j = 0; j < gg[v].size(); j++){ int to = gg[v][j]; if (delt[to]) continue; --kol[to]; if (used[to]) continue; if (clr[to] == c){ vec.push_back(to); } else if (kol[to] == 0){ vec.push_back(to); } } } } vector <int> vec; bool solve(){ vector <int> fvec; for (int i = 0; i < vec.size(); i++){ if (chrg[vec[i]]) fvec.push_back(vec[i]); } f(fvec, 0); fvec.clear(); for (int i = 0; i < vec.size(); i++){ if (!used[vec[i]]) fvec.push_back(vec[i]); } f(fvec, 1); bool bb = 0; for (int i = vec.size()-1; i >= 0; i--){ if (used[vec[i]]){ bb = 1; delt[vec[i]] = 1; swap(vec[i], vec.back()); vec.pop_back(); } } return bb; } std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) { vector <int> ansvec; n = a.size(); for (int i = 0; i < n; i++){ g[i].clear(); gg[i].clear(); clr[i] = a[i]^1; chrg[i] = r[i]; } for (int i = 0; i < u.size(); i++){ g[u[i]].push_back(v[i]); gg[v[i]].push_back(u[i]); rebr.push_back({u[i], v[i]}); } for (int i = 0; i < n; i++){ vec.push_back(i); } while(solve()){ } ansvec.resize(n); for (int i = 0; i < vec.size(); i++){ ansvec[vec[i]] = 1; } return ansvec; } /** 2 4 0 1 1 0 0 0 0 1 1 0 1 1 */

Compilation message (stderr)

train.cpp: In function 'void cler()':
train.cpp:21:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < rebr.size(); i++){
                     ~~^~~~~~~~~~~~~
train.cpp: In function 'void f(std::vector<int>, int)':
train.cpp:37:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int j = 0; j < gg[v].size(); j++){
                         ~~^~~~~~~~~~~~~~
train.cpp: In function 'bool solve()':
train.cpp:57:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < vec.size(); i++){
                     ~~^~~~~~~~~~~~
train.cpp:63:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < vec.size(); i++){
                     ~~^~~~~~~~~~~~
train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:89:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < u.size(); i++){
                     ~~^~~~~~~~~~
train.cpp:102:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < vec.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...