QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#420048 | #8593. Coin | UmairAhmadMIrza# | 0 | 1ms | 3828kb | C++20 | 616b | 2024-05-24 14:18:47 | 2024-05-24 14:18:49 |
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int const N=1005;
int const mod=1e9+7;
set<int> ls[N],gr[N];
int ans[N];
int main(){
int n,m;
cin>>n>>m;
for (int i = 1; i <=n; ++i)
ans[i]=-1;
for(int i=1;i<=m;i++){
int a,b;
cin>>a>>b;
ls[b].insert(a);
gr[a].insert(b);
for(auto i:ls[a])
ls[b].insert(i);
for(auto i:gr[b])
gr[a].insert(i);
if(ans[a]==-1 && ls[a].size()+gr[a].size()==n-1)
ans[a]=i;
if(ans[b]==-1 && ls[b].size()+gr[b].size()==n-1)
ans[b]=i;
}
for(int i=1;i<=n;i++)
cout<<ans[i]<<' ';
cout<<endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 6
Accepted
time: 1ms
memory: 3828kb
input:
4 4 2 4 3 1 4 1 2 3
output:
3 4 -1 -1
result:
ok ac
Test #2:
score: 0
Wrong Answer
time: 0ms
memory: 3704kb
input:
6 8 1 5 5 4 6 2 2 5 4 3 6 1 6 5 2 1
output:
-1 -1 -1 -1 -1 -1
result:
wrong answer wa
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%