제출 #70053

#제출 시각아이디문제언어결과실행 시간메모리
70053bnahmad15장난감 기차 (IOI17_train)C++17
10 / 100
162 ms1560 KiB
#include "train.h" #include <bits/stdc++.h> using namespace std; const int N = 5001; int n,is[N],vis[N],own[N]; vector <int> g[N],S; int dfs(int u){ vis[u] = 1; S.push_back(u); int ret; if(own[u] == 0){ ret = 1; for(int i = 0;i<g[u].size();i++){ int v = g[u][i]; if(vis[v] == 1){ int flag = 0; for(int j = S.size()-1;j>=0;j--){ if(is[S[j]] == 1){ flag = 1; break; } if(S[j] == v) break; } ret = min(ret,flag); }else{ ret = min(ret,dfs(v)); } } }else{ ret = 0; for(int i = 0;i<g[u].size();i++){ int v = g[u][i]; if(vis[v] == 1){ int flag = 0; for(int j = S.size()-1;j>=0;j--){ if(is[S[j]] == 1){ flag = 1; break; } if(S[j] == v) break; } ret = max(ret,flag); }else{ ret = max(ret,dfs(v)); } } } vis[u] = 0; S.pop_back(); return ret; } 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<u.size();i++){ g[u[i]].push_back(v[i]); } for(int i = 0;i<n;i++) is[i] = r[i]; for(int i = 0;i<n;i++) own[i] = a[i]; if(n <= 15){ int cnt = 0; for(int i = 0;i<n;i++){ for(int j = 0;j<n;j++){ vis[j] = 0; } cnt++; res.push_back(dfs(i)); } } return res; }

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

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