Submission #783747

#TimeUsernameProblemLanguageResultExecution timeMemory
783747christinelynnNaboj (COCI22_naboj)C++17
110 / 110
445 ms18500 KiB
#include<bits/stdc++.h> #define ll long long #define fi first #define sec second #define pb push_back #define pqueue priority_queue #define int long long #define pii pair<int,int> #define supercepat ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0); using namespace std; int tc,ans=0,n,m; int in1,in2; vector<int> adj[200005]; bool vis[200005]; int point[200005]; vector<int> topo; void dfs(int x){ if(vis[x]) return; vis[x]=1; topo.pb(x); for(auto i : adj[x]){ point[i]--; if(point[i]==0){ dfs(i); } } } main(){ supercepat; cin>>n>>m; for(int i=1;i<=m;i++){ cin>>in1>>in2; adj[in2].pb(in1); point[in1]++; } for(int i=1;i<=n;i++){ if(point[i]==0&&!vis[i]){ dfs(i); } } if(topo.size()!=n){ cout<<-1<<endl; } else{ cout<<topo.size()<<endl; for(auto i : topo){ cout<<i<<" "<<1<<endl; } } }

Compilation message (stderr)

naboj.cpp:28:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   28 | main(){
      | ^~~~
naboj.cpp: In function 'int main()':
naboj.cpp:41:17: 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]
   41 |   if(topo.size()!=n){
      |      ~~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...