Submission #783682

#TimeUsernameProblemLanguageResultExecution timeMemory
783682makanhuliaNaboj (COCI22_naboj)C++17
0 / 110
388 ms14904 KiB
#include <bits/stdc++.h> #include <bits/stdc++.h> using namespace std; #define ll long long int #define cy cout<<"YES"<<endl #define cn cout<<"NO"<<endl #define repp(i,n,k) for(int i=1;i<=n;i+=k) #define repo(i,n,k) for(int i=0;i<n;i+=k) #define pb push_back using namespace std; ll arr[200005]; vector<ll> adj[200005]; vector<ll> ans; int main(){ ll m,n;cin>>m>>n; queue<ll> q; for(int i=1;i<=n;i++){ ll a,b;cin>>a>>b; adj[a].push_back(b); arr[b]++; } repp(i,n,1){ if(arr[i]==0) q.push(i); } while(!q.empty()){ ll cur=q.front(); ans.pb(cur); q.pop(); for(ll nx:adj[cur]){ arr[nx]--; if(arr[nx]==0) q.push(nx); } } if(ans.size()!=m) cout<<"-1"; else { cout<<ans.size()<<endl; for(ll nx:ans){ cout<<nx<<" 0"<<endl; } } }

Compilation message (stderr)

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