QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#480397 | #995. 桥 | ucup-team1004# | RE | 0ms | 0kb | C++17 | 1.1kb | 2024-07-16 15:13:54 | 2024-07-16 15:13:54 |
answer
#include<bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#include"debug.h"
#else
#define debug(...) void()
#endif
#define all(x) (x).begin(),(x).end()
template<class T>
auto ary(T *a,int l,int r){
return vector<T>{a+l,a+1+r};
}
using ll=long long;
using ull=unsigned long long;
const int N=1e5+10;
int n,m;
int kk=1,head[N];
struct edges{
int to,nex;
}e[N*2];
void add(int u,int v){
e[++kk]={v,head[u]},head[u]=kk;
e[++kk]={u,head[v]},head[v]=kk;
}
int dft,sct,dfn[N],scc[N],low[N];
void tarjan(int u,int las=-1){
static int top,stk[N];
dfn[u]=low[u]=++dft,stk[++top]=u;
for(int i=head[u];i;i=e[i].nex)if(i^las^1){
int v=e[i].to;
if(!dfn[v])tarjan(v,i),low[u]=min(low[u],low[v]);
else if(!scc[v])low[u]=min(low[u],dfn[v]);
}
if(dfn[u]==low[u]){
sct++;
do scc[stk[top]]=sct;while(stk[top--]^u);
}
}
int main(){
scanf("%d%d",&n,&m);
vector<pair<int,int>>E(m);
for(auto &[u,v]:E){
scanf("%d%d",&u,&v),add(u,v);
}
for(int i=1;i<=n;i++)if(!dfn[i])tarjan(i);
for(auto [u,v]:E){
if(scc[u]!=scc[v])printf("%d %d\n",u,v);
}
return 0;
}
#ifdef DEBUG
#include"debug.hpp"
#endif
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...