# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
534136 |
2022-03-08T01:32:25 Z |
perchuts |
Pipes (CEOI15_pipes) |
C++17 |
|
351 ms |
28996 KB |
#include <bits/stdc++.h>
#define maxn (int)(1e5+51)
#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define endl '\n'
#define ll long long
#define pb push_back
#define ull unsigned long long
#define ii pair<int,int>
#define iii tuple<int,int,int>
#define inf 2000000001
#define mod 1000000007 //998244353
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
template<typename X, typename Y> bool ckmin(X& x, const Y& y) { return (y < x) ? (x=y,1):0; }
template<typename X, typename Y> bool ckmax(X& x, const Y& y) { return (x < y) ? (x=y,1):0; }
int n,m,dp[100001], lvl[100001];
pair<int,int> edges[2000001];
int getAdj(int u){
return lower_bound(edges,edges+2*m,make_pair(u,0)) - edges;
}
int dfs(int u,int p){
for(int i = getAdj(u);i<2*m&&edges[i].first==u;++i){
int v = edges[i].second;
if(lvl[v]==0){
lvl[v] = lvl[u]+1;
dp[u] += dfs(v,u);
}else if(lvl[v]>lvl[u]){
dp[u]--;
}else{
dp[u]++;
}
}
dp[u]--;
if(dp[u]==0&&lvl[u]!=1)cout<<u<<" "<<p<<endl;
return dp[u];
}
int main(){_
cin>>n>>m;
for(int i=0;i<m;++i){
int a,b;cin>>a>>b;
edges[2*i] = {a,b};
edges[2*i+1] = {b,a};
}
sort(edges,edges+2*m);
for(int i=0;i<2*m;++i){
if(!lvl[edges[i].first]){
lvl[edges[i].first] = 1;
dfs(edges[i].first,edges[i].first);
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
844 KB |
Output is correct |
2 |
Correct |
4 ms |
588 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
219 ms |
10440 KB |
Output is correct |
2 |
Correct |
226 ms |
9892 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
351 ms |
16460 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
173 ms |
17100 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
151 ms |
16716 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
152 ms |
18504 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
156 ms |
28964 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
172 ms |
28996 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
160 ms |
28960 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |