Submission #782210

#TimeUsernameProblemLanguageResultExecution timeMemory
782210christinelynnNaboj (COCI22_naboj)C++17
0 / 110
324 ms16308 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll n,m; vector <ll> al[200005]; ll deg[200005]; int main(){ cin>>n>>m; queue<ll> q; for (int i=1;i<=m;i++){ ll a,b; cin>>a>>b; al[b].push_back(a); deg[a]++; } vector <pair<ll,ll>> ans; for (int i=1;i<=n;i++){ if (deg[i]==0) { q.push(i); ans.push_back({i,0}); } } while(!q.empty()){ ll u=q.front(); q.pop(); for (auto z:al[u]){ deg[z]--; if (deg[z]==0){ ans.push_back({z,0}); q.push(z); } } } if (ans.size()!=n) cout<<-1; else{ for (auto z:ans){ cout<<z.first<<" "<<z.second<<endl; } } }

Compilation message (stderr)

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