제출 #847093

#제출 시각아이디문제언어결과실행 시간메모리
847093PacybwoahNaboj (COCI22_naboj)C++17
110 / 110
159 ms20208 KiB
#include<iostream> #include<vector> #include<queue> #include<utility> #include<algorithm> using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(0); int n,m; cin>>n>>m; vector<int> deg(n+1); vector<vector<int> > graph(n+1); int a,b; for(int i=0;i<m;i++){ cin>>a>>b; deg[b]++; graph[a].push_back(b); } vector<int> topo; queue<int> q; for(int i=1;i<=n;i++) if(deg[i]==0) q.push(i); while(!q.empty()){ int node=q.front(); q.pop(); topo.push_back(node); for(auto x:graph[node]){ deg[x]--; if(deg[x]==0) q.push(x); } } if(topo.size()!=n) cout<<-1; else {cout<<n<<"\n";for(auto x:topo) cout<<x<<' '<<0<<"\n";} }

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

naboj.cpp: In function 'int main()':
naboj.cpp:32:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   32 |     if(topo.size()!=n) cout<<-1;
      |        ~~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...