제출 #69902

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

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

train.cpp: In function 'void dfs(int)':
train.cpp:13: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:44:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0;i<u.size();i++){
                ~^~~~~~~~~
train.cpp:58:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int j = 0;j<need.size();j++){
                  ~^~~~~~~~~~~~
train.cpp:62:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int j = 0;j<need.size();j++){
                   ~^~~~~~~~~~~~
#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...