QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#480202 | #995. 桥 | Hanghang# | WA | 302ms | 69576kb | C++14 | 784b | 2024-07-16 10:09:38 | 2024-07-16 10:09:38 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+3;
int n,m,tim,f[N],dfn[N],low[N],kx[N],ky[N];
map<pair<int,int>,int>mp;
bool vis[N];
vector<int>ve[N];
int F(int x){return f[x]==x?x:f[x]=F(f[x]);}
void Dfs(int x,int fa)
{
low[x]=dfn[x]=++tim;
for(int y:ve[x])
{
if(y==fa){fa=0;continue;}
if(dfn[y]){low[x]=min(low[x],dfn[y]);continue;}
Dfs(y,x);low[x]=min(low[x],low[y]);
if(low[y]>dfn[x])vis[mp[make_pair(x,y)]]=1;
}
}
int main()
{
cin>>n>>m;
for(int i=1,x,y;i<=m;i++)
{
cin>>x>>y;
if(x==y)continue;
ve[x].push_back(y),ve[y].push_back(x);
mp[make_pair(x,y)]=i,kx[i]=x,ky[i]=y;
}
for(int i=1;i<=n;i++)if(!dfn[i])Dfs(i,0);
for(int i=1;i<=m;i++)if(vis[i])cout<<kx[i]<<" "<<ky[i]<<endl;
}
详细
Test #1:
score: 100
Accepted
time: 302ms
memory: 69576kb
input:
24942 387166 12556 21443 22404 16376 11073 24296 1535 11968 23745 2818 5073 12731 22550 14761 24118 12008 22695 18979 15118 13639 2080 8721 692 22578 22581 15267 9278 4127 7457 21674 17693 23448 10949 23429 9700 6009 14140 5064 7742 15164 17336 1662 18903 9760 17645 19575 6540 11942 11 4937 15282 10...
output:
result:
ok 0 lines
Test #2:
score: 0
Accepted
time: 58ms
memory: 40928kb
input:
10599 87159 4698 4000 60 4705 1476 5947 7273 1716 8004 3018 10094 1717 3092 3493 2613 9681 5427 3723 2510 6343 10113 6322 9257 634 4996 10197 9918 5582 6348 9561 10536 9777 8133 540 1917 7838 6666 2220 7951 815 2873 977 9397 4991 3529 1395 1426 3874 6379 9098 9504 3437 9076 9134 4321 3879 10252 9390...
output:
result:
ok 0 lines
Test #3:
score: -100
Wrong Answer
time: 95ms
memory: 47364kb
input:
43236 126833 40500 20695 21481 27642 28098 41772 412 7750 5862 39561 21777 22303 7868 21217 31658 34299 18532 10934 21931 31023 42926 15624 40332 18017 12484 8663 21927 7910 12504 17943 4379 10252 3523 21794 18641 1965 18633 25061 14639 10800 35958 1441 35044 20249 31491 38161 5749 4468 13403 8413 3...
output:
38008 17235 40329 42530 19516 26641 43027 24643 29027 35410 35388 534 30628 31979 38444 33887 28554 31809 39630 34623 16150 42137 13811 35147 3120 17275 36681 294 28872 23185 34632 38375 33548 29449 4954 1043 38501 561 28012 22768 15633 12291 40368 37763 17669 24284 36038 12307 27702 24596 18937 576...
result:
wrong answer 1st lines differ - expected: '1349 20915', found: '38008 17235'