제출 #138325

#제출 시각아이디문제언어결과실행 시간메모리
138325almogwald장난감 기차 (IOI17_train)C++14
0 / 100
12 ms1656 KiB
#include <utility> #include <algorithm> #include "train.h" #define fori(i,n) for(int i=0;i<n;i++) #define forib(i,n) for(int i=n-1;i>=0;i--) #define maxl 10000000000 typedef long long lol; using namespace std; vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) { int n=a.size(); vector<int> res(n,1); vector<vector<int>> cons(n); vector<vector<int>> opcons(n); fori(i,u.size()){ int cur=u[i]; int next=v[i]; cons[cur].push_back(next); opcons[next].push_back(cur); } int cur=0; vector<int>left(n); fori(i,n){ if(r[i]){ cur=i; } if(a[i]){ left[i]=1; }else{ left[i]=cons[i].size(); } } vector<int> help; fori(j,opcons[cur].size()){ int curr=opcons[cur][j]; left[curr]--; if(left[curr]==0){ res[curr]=1; if(cur!=curr){ help.push_back(curr); } } } while(help.size()){ int i=help.back(); help.pop_back(); fori(j,opcons[i].size()){ int curr=opcons[i][j]; left[curr]--; if(left[curr]==0){ res[curr]=1; if(cur!=curr){ help.push_back(curr); } } } } if(res[cur]==0){ fori(i,n){ res[i]=0; } } return res; }

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

train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:5:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define fori(i,n) for(int i=0;i<n;i++)
train.cpp:16:7:
  fori(i,u.size()){
       ~~~~~~~~~~                
train.cpp:16:2: note: in expansion of macro 'fori'
  fori(i,u.size()){
  ^~~~
train.cpp:5:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define fori(i,n) for(int i=0;i<n;i++)
train.cpp:36:7:
  fori(j,opcons[cur].size()){
       ~~~~~~~~~~~~~~~~~~~~      
train.cpp:36:2: note: in expansion of macro 'fori'
  fori(j,opcons[cur].size()){
  ^~~~
train.cpp:5:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define fori(i,n) for(int i=0;i<n;i++)
train.cpp:49:8:
   fori(j,opcons[i].size()){
        ~~~~~~~~~~~~~~~~~~       
train.cpp:49:3: note: in expansion of macro 'fori'
   fori(j,opcons[i].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...