Submission #1116034

# Submission time Handle Problem Language Result Execution time Memory
1116034 2024-11-21T08:08:04 Z vjudge1 Pipes (CEOI15_pipes) C++17
30 / 100
229 ms 55928 KB
#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
1 Correct 1 ms 336 KB Output is correct
2 Incorrect 1 ms 460 KB Wrong number of edges
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 848 KB Output is correct
2 Incorrect 4 ms 848 KB Wrong number of edges
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 75 ms 4556 KB Output is correct
2 Correct 83 ms 4104 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 137 ms 6892 KB Output is correct
2 Correct 150 ms 8776 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 229 ms 14764 KB Output is correct
2 Correct 186 ms 11812 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 39 ms 21420 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 76 ms 30268 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 88 ms 39824 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 97 ms 47940 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 122 ms 55928 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -