This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define pb push_back
#define spc << " " <<
#define endl "\n"
#define all(x) x.begin(), x.end()
//#define int long long
#define ii pair<int, int>
#define vi vector<int>
#define vii vector<ii>
#define st first
#define nd second
#define mid (l+r)/2
#define inf 1e15
#define MOD 998244353
#define MX 1005
using namespace std;
vector<vector<int16_t>> edges;
vector<int16_t> dp, vis;
void dfs(int16_t node, int16_t par){
vis[node]=(int16_t)1;
for(auto i:edges[node]){
if(i==par || vis[i]==-1) continue;
if(vis[i]==1){
dp[node]--;
dp[i]++;
continue;
}
dfs(i, node);
dp[node]+=dp[i];
}
vis[node]=-1;
if(par!=0 && dp[node]==(int16_t)0) cout << node spc par << endl;
}
void solve(){
int n,m; cin >> n >> m;
edges.resize(n+1);
dp.resize(n+1, 0);
vis.resize(n+1, 0);
int16_t a,b;
for(int i=1; i<=m; i++){
cin >> a >> b;
edges[a].pb(b);
edges[b].pb(a);
}
for(int16_t i=1; i<=n; i++){
if(vis[i]==0) dfs(i, 0);
}
}
signed main(){
ios_base::sync_with_stdio(false);cin.tie(0);
#ifdef Local
freopen("in","r",stdin);
freopen("out","w",stdout);
/*#else
freopen("","r",stdin);
freopen("","w",stdout);*/
#endif
int t=1;
//cin >> t;
while(t--) solve();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |