Submission #908732

# Submission time Handle Problem Language Result Execution time Memory
908732 2024-01-16T17:48:44 Z nasir_bashirov Easter Eggs (info1cup17_eastereggs) C++11
10 / 100
4 ms 1956 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
 
#define db long double
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define endl '\n'
#define all(x) x.begin(), x.end()
#define fastio\
    ios_base::sync_with_stdio(0);\
    cin.tie(0);\
    cout.tie(0)\
 
vi sub[550];
vi g[550];
 
void dfs(int node, int par){
    sub[node].push_back(node);
    for(int i : g[node]){
        if(i == par)    continue;
        dfs(i, node);
        for(int j : sub[i]){
            sub[node].push_back(j);
        }
    }
}
 
int findEgg (int n, vii bridges){
    for(int i = 1; i <= n; i++){
        g[i].clear(), sub[i].clear();
    }
    for(pii i : bridges){
        g[i.first].push_back(i.second);
        g[i.second].push_back(i.first);
    }
    dfs(1, 1);
    int cur = 1, par = 1;
    while(true){
        int nxt = -1;
        for(int i : g[cur]){
            if(i == par)    continue;
            if(query(sub[i])){
                nxt = i;
                break;
            }
        }
        if(nxt == -1)   return cur;
        par = cur, cur = nxt;
    }
}
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 344 KB Number of queries: 9
2 Partially correct 1 ms 344 KB Number of queries: 8
3 Partially correct 1 ms 344 KB Number of queries: 10
4 Partially correct 1 ms 344 KB Number of queries: 15
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 900 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 1956 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -