QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#420175 | #8593. Coin | Muhammad-Saram# | 0 | 1ms | 3580kb | C++17 | 747b | 2024-05-24 15:05:14 | 2024-05-24 15:05:15 |
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
signed main()
{
int n,m;
cin>>n>>m;
int ans[n];
for (int i=0;i<n;i++)
ans[i]=-1;
set<int> le[n],gr[n];
for (int we=1;we<=m;we++)
{
int u,v;
cin>>u>>v;
u--,v--;
le[v].insert(u);
gr[u].insert(v);
for (int i:le[u])
for (int j:gr[v])
{
le[j].insert(i);
gr[i].insert(j);
}
for (int i:le[u])
le[v].insert(i);
for (int i:gr[v])
gr[u].insert(i);
for (int i=0;i<n;i++)
{
if (ans[i]==-1 and gr[i].size()+le[i].size()==n-1)
ans[i]=we;
}
}
for (int i=0;i<n;i++)
cout<<ans[i]<<' ';
cout<<endl;
return 0;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 6
Accepted
time: 1ms
memory: 3580kb
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: 3512kb
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%