제출 #296818

#제출 시각아이디문제언어결과실행 시간메모리
296818DanerZein장난감 기차 (IOI17_train)C++14
0 / 100
177 ms262148 KiB
#include "train.h" #include <bits/stdc++.h> using namespace std; typedef vector<int> vi; vector<vi> G; bitset<5010> ab,cs,cl; int vis[5010]; vi res,path; int n; bool dfs(int u){ vis[u]=1; if(ab[u] and cs[u] and cl[u]){ return res[u]=1; } if(!ab[u] and !cs[u] and cl[u]){ return res[u]=0; } bool ans=0; for(auto &v:G[u]){ ans=dfs(v); } if(G[u].size()==0){ if(ab[u] and !cs[u]){ ans=0; } if(!ab[u] and cs[u]){ ans=1; } } return res[u]=ans; } bool ciclo(int u,bool ch){ vis[u]=1; bool sw=0; if(cs[u]) ch=1; for(auto &v:G[u]){ if(vis[v]==1 and ch){ return 1; } if(!vis[v]){ sw|=ciclo(v,ch); } } return sw; } void arezou(){ for(int i=0;i<n;i++){ memset(vis,-1,sizeof vis); if(cs[i]) res[i]=ciclo(i,1); else res[i]=ciclo(i,0); } } std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) { bool tw=0; n=a.size(); for(int i=0;i<a.size();i++){ if(a[i]==0) tw=1; ab[i]=a[i]; cs[i]=r[i]; } G.resize(n+1); res.resize(n); for(int i=0;i<u.size();i++){ int x=u[i],y=v[i]; if(x!=y) G[x].push_back(y); if(x==y and tw==1) cl[x]=1; } memset(vis,-1,sizeof vis); if(tw==1){ for(int i=0;i<n;i++){ if(vis[i]==-1){ res[i]=dfs(i); } } } else{ arezou(); } return res; }

컴파일 시 표준 에러 (stderr) 메시지

train.cpp: In function 'bool dfs(int)':
train.cpp:13:18: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   13 |     return res[u]=1;
train.cpp:16:18: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   16 |     return res[u]=0;
train.cpp:30:16: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   30 |   return res[u]=ans;
train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:57:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |   for(int i=0;i<a.size();i++){
      |               ~^~~~~~~~~
train.cpp:64:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |   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...