Submission #775580

#TimeUsernameProblemLanguageResultExecution timeMemory
775580APROHACKToy Train (IOI17_train)C++14
0 / 100
153 ms1660 KiB
#include "train.h" #include<bits/stdc++.h> #define pb push_back #define ll long long #define ff first #define ss second using namespace std; int contNode[5001]; bool isFA[5001]; bool isFB[5001]; bool owner[5001], rechargable[5001], vis[5001]; bool answered[5001]; vector<int>adj[5001], inv[5001]; int n, m; void restart(){ for(int i = 0 ; i < n; i ++){ isFA[i] = false; isFB[i] = false; vis[i] = false; contNode[i] = 0; } } void restart2(){ for(int i = 0 ; i < n; i ++){ //isFA[i] = false; //isFB[i] = false; vis[i] = false; contNode[i] = 0; } } void getA(){ queue<int>llegado; for(int i = 0 ; i < n ;i ++){ if(rechargable[i] and !answered[i]){ llegado.push(i); isFA[i] = true; } } while(!llegado.empty()){ int cur = llegado.front(); llegado.pop(); int v; for(int i = 0 ; i < inv[cur].size() ; i ++){ v = inv[cur][i]; if(vis[v] or answered[v])continue; if(owner[v] or contNode[v] + 1 == adj[v].size()){ llegado.push(v); isFA[v] = true; vis[v] = true; }else contNode[v] ++; } } } void getB(){ queue<int>llegado; for(int i = 0 ; i < n ; i ++){ if(!isFA[i] and !answered[i]){ isFB[i] = true; llegado.push(i); } } while(!llegado.empty()){ int cur = llegado.front(); llegado.pop(); int v; for(int i = 0 ; i < inv[cur].size() ; i ++){ v = inv[cur][i]; if(vis[v] or answered[v])continue; if(!owner[v] or contNode[v] + 1 == adj[v].size()){ llegado.push(v); isFB[v] = true; vis[v] = true; }else contNode[v] ++; } } } std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) { n = r.size(); m = u.size(); vector<int>ans; for(int i = 0 ; i < n ;i ++){ owner[i] = a[i]; rechargable[i] = r[i]; ans.pb(1); } for(int i = 0 ; i < m ; i ++){ adj[u[i]].pb(v[i]); inv[v[i]].pb(u[i]); } do{ restart(); getA(); restart2(); getB(); bool quedo = false; for(int i = 0 ; i < n ; i ++){ if(!answered[i] and isFB[i]){ answered[i] = true; quedo = true; ans[i] = 0; } } if(!quedo)return ans; }while(true); }

Compilation message (stderr)

train.cpp: In function 'void getA()':
train.cpp:45:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |   for(int i = 0 ; i < inv[cur].size() ; i ++){
      |                   ~~^~~~~~~~~~~~~~~~~
train.cpp:48:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |    if(owner[v] or contNode[v] + 1 == adj[v].size()){
      |                   ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
train.cpp: In function 'void getB()':
train.cpp:68:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |   for(int i = 0 ; i < inv[cur].size() ; i ++){
      |                   ~~^~~~~~~~~~~~~~~~~
train.cpp:71:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   71 |    if(!owner[v] or contNode[v] + 1 == adj[v].size()){
      |                    ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
#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...