Submission #69899

#TimeUsernameProblemLanguageResultExecution timeMemory
69899bnahmad15Toy Train (IOI17_train)C++17
0 / 100
1154 ms3412 KiB
#include "train.h" #include <bits/stdc++.h> using namespace std; const int N = 5001; int n,vis[N],tim[N],cnt = 0; int is[N],no[N],can[N]; vector <int> g[N]; int dfs(int u,int found){ tim[u] = ++cnt; vis[u] = 1; no[tim[u]] = 1; int res = 0; if(is[u] == 1) found = tim[u]; // cout<<u<<" "<<is[u]<<" "<<found<<" "<<cnt<<endl; for(int i = 0;i<g[u].size();i++){ int v = g[u][i]; if(vis[v] == 2){ // cout<<res<<" "; continue; } else if(vis[v] == 1){ res = max(res,no[found] & (found >= tim[v]) ? 1 : 0); // cout<<res<<" "; continue; }else{ res = max(res,dfs(v,found)); } // cout<<res<<" "; } // cout<<endl; no[tim[u]] = 0; vis[u] = 2; can[u] |= res; return res; } std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) { std::vector<int> res; n = a.size(); for(int i = 0;i<n;i++){ is[i] = 0; } for(int i = 0;i<r.size();i++){ if(r[i] == 1) is[i] = 1; } for(int i = 0;i<u.size();i++){ g[u[i]].push_back(v[i]); } for(int i = 0;i<n;i++){ if(can[i] == 1){ res.push_back(1); }else{ for(int j = 0;j<n;j++){ vis[j] = 0; tim[j] = -1; } cnt = 0; res.push_back(dfs(i,-1)); } // cout<<endl; } return res; }

Compilation message (stderr)

train.cpp: In function 'int dfs(int, int)':
train.cpp:18:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0;i<g[u].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:46:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0;i<r.size();i++){
                ~^~~~~~~~~
train.cpp:50:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  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...