# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
783747 | christinelynn | Naboj (COCI22_naboj) | C++17 | 445 ms | 18500 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |