답안 #230506

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
230506 2020-05-10T09:15:42 Z zoooma13 Easter Eggs (info1cup17_eastereggs) C++14
0 / 100
16 ms 888 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;

#define MAX_N 513

vector <int> adj[MAX_N] ,active ,Set;

int SZ;
void dfs(int u ,int p=-1){
    if(!SZ)
        return;
    Set.push_back(u);
    if(find(active.begin() ,active.end() ,u) != active.end())
        SZ--;
    for(int&v : adj[u]) if(v != p)
        dfs(v ,u);
}
vector <int> findSet(int sz){
    SZ = sz;
    Set.clear();
    dfs(1);
    return Set;
}

int findEgg (int N, vector < pair < int, int > > bridges){
    for(auto&e : bridges)
        adj[e.first].push_back(e.second),
        adj[e.second].push_back(e.first);

    active.resize(N);
    iota(active.begin() ,active.end() ,1);

    while(active.size() > 1){
        vector <int> vs = findSet(((int)active.size())/2);
        if(query(vs)){
            vector <int> nv;
            for(int&v : vs)
                if(find(active.begin() ,active.end() ,v) != active.end())
                    nv.push_back(v);
            active = nv;
        }else{
            for(int&v : vs)
                if(find(active.begin() ,active.end() ,v) != active.end())
                    active.erase(find(active.begin() ,active.end() ,v));
        }
    }

    return active.front();
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 6 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 16 ms 888 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -