Submission #440459

# Submission time Handle Problem Language Result Execution time Memory
440459 2021-07-02T10:04:19 Z zxcvbnm Easter Eggs (info1cup17_eastereggs) C++14
0 / 100
400 ms 131076 KB
#include <bits/stdc++.h>
#include "grader.h"

using namespace std;
const int maxN = 515;
vector<int> kids[maxN];
vector<int> adj[maxN];
vector<int> sz(maxN);
vector<bool> in(maxN, true);

void dfs(int v, int p) {

    for(int u : adj[v]) {
        if (u == p || !in[u]) continue;
        dfs(u, v);
        kids[v].push_back(u);
        sz[v] += sz[u];
    }
}

vector<int> find_kids(int v) {
    vector<int> ans;
    ans.push_back(v);

    for(int u : kids[v]) {
        vector<int> f = find_kids(u);
        for(int g : f) {
            ans.push_back(g);
        }
    }
    return ans;
}

int findEgg (int N, vector < pair < int, int > > bridges)
{
    for(auto i : bridges) {
        adj[i.first].push_back(i.second);
        adj[i.second].push_back(i.first);
    }
    int lg = ceil(log2(N));
    for(int i = 1; i <= lg; i++) {
        sz.assign(maxN, 1);
        for(int j = 1; j <= N; j++) {
            kids[j].clear();
        }
        for(int j = 1; j <= N; j++) {
            if (in[j]) {
                dfs(j, j);
                break;
            }
        }
//        for(int j = 1; j <= N; j++) {
//            if (sz[j] == N / (1<<i)) {
//                vector<int> f = find_kids(j);
//                bool ok = query(f);
//                if (!ok) {
//                    for(int k : f) {
//                        in[k] = false;
//                    }
//                } else {
//                    fill(in.begin(), in.end(), false);
//                    for(int k : f) {
//                        in[k] = true;
//                    }
//                }
//            }
//        }
    }

    int ans = -1;
    for(int i = 1; i <= N; i++) {
        if (in[i]) {
            ans = i;
        }
    }

    assert(ans != -1);
    return ans;
}
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 328 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 540 ms 131076 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 564 ms 131076 KB Time limit exceeded
2 Halted 0 ms 0 KB -