QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#676786 | #995. 桥 | lsj2009 | RE | 0ms | 0kb | C++20 | 1.7kb | 2024-10-26 00:41:32 | 2024-10-26 00:41:33 |
answer
#include<bits/stdc++.h>
//#pragma GCC optimize(3,"Ofast","inline")
//#define int long long
#define i128 __int128
#define ll long long
#define ull unsigned long long
#define uint unsigned int
#define ld double
#define PII pair<int,int>
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f
#define chkmax(a,b) a=max(a,b)
#define chkmin(a,b) a=min(a,b)
#define rep(k,l,r) for(int k=l;k<=r;++k)
#define per(k,r,l) for(int k=r;k>=l;--k)
#define cl(f,x) memset(f,x,sizeof(f))
#define pcnt(x) __builtin_popcount(x)
#define lg(x) (31-__builtin_clz(x))
using namespace std;
void file_IO() {
// system("fc .out .ans");
freopen(".in","r",stdin);
freopen(".out","w",stdout);
}
bool M1;
const int N=1e5+5,M=5e5+5;
int head[N],len;
struct node {
int to,w,nxt;
}; node edge[M<<1];
void add_edge(int u,int v,int w) {
edge[++len]={v,w,head[u]}; head[u]=len;
}
int dfn[N],low[N],p;
vector<int> vec;
void tarjan(int u,int bl) {
low[u]=dfn[u]=++p;
for(int i=head[u];i;i=edge[i].nxt) {
int v=edge[i].to,w=edge[i].w;
if(!dfn[v]) {
tarjan(v,w);
if(low[v]>dfn[u])
vec.push_back(w);
chkmin(low[u],low[v]);
} else if(w!=bl)
chkmin(low[u],dfn[v]);
}
}
int a[N],b[N];
void solve() {
int n,m;
scanf("%d%d",&n,&m);
rep(i,1,m) {
scanf("%d%d",&a[i],&b[i]);
add_edge(a[i],b[i],i);
add_edge(b[i],a[i],i);
}
rep(i,1,n) {
if(!dfn[i])
tarjan(i,0);
}
sort(vec.begin(),vec.end());
for(auto x:vec)
printf("%d %d\n",a[x],b[x]);
}
bool M2;
signed main() {
//file_IO();
int testcase=1;
//scanf("%d",&testcase);
while(testcase--)
solve();
fprintf(stderr,"used time = %ldms\n",1000*clock()/CLOCKS_PER_SEC);
fprintf(stderr,"used memory = %lldMB\n",(&M2-&M1)/1024/1024);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Runtime Error
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...