Submission #242999

# Submission time Handle Problem Language Result Execution time Memory
242999 2020-06-30T07:16:31 Z AndyIzGay Easter Eggs (info1cup17_eastereggs) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
vector<vi> AdjList;
vi qr;
vector<bool> num,ok;
int cur,cnt,n,tmp;
void dfs(int v, int p) {
    if(tmp==cur) return;
    if(ck[v]) cur++;
    ans.push_back(v);
    for(int u: AdjList[v]) {
        if(u==p) continue;
        else dfs(u,v)
    }
}
int findEgg(int n, vii edges) {
    AdjList.assign(n+1,vi());
    num.assign(n+1,-1);
    ck.assign(n+1,1);
    cnt=n;
    for(ii t: edges) {
        AdjList[t.first].push_back(t.second);
        AdjList[t.second].push_back(t.first);
    }
    while(cnt!=1) {
        tmp=(cnt+1)/2;
        cur=0;
        qr.clear();
        dfs(1,1);
        if(query(qr)) {
            for(int i=1 ; i<=n ; i++) num[i]=0;
            for(int i: qr) num[i]=ck[i];
            for(int i=1 ; i<=n ; i++) ck[i]=num[i];
            cnt=tmp;
        }
        else {
            for(int i: qr) {
                ck[i]=0;
            }
            cnt-=tmp;
        }
    }
    for(int i=1 ; i<=n ; i++) {
        if(ck[i]) return i;
    }
}

Compilation message

eastereggs.cpp: In function 'void dfs(int, int)':
eastereggs.cpp:12:8: error: 'ck' was not declared in this scope
     if(ck[v]) cur++;
        ^~
eastereggs.cpp:12:8: note: suggested alternative: 'ok'
     if(ck[v]) cur++;
        ^~
        ok
eastereggs.cpp:13:5: error: 'ans' was not declared in this scope
     ans.push_back(v);
     ^~~
eastereggs.cpp:13:5: note: suggested alternative: 'abs'
     ans.push_back(v);
     ^~~
     abs
eastereggs.cpp:17:5: error: expected ';' before '}' token
     }
     ^
eastereggs.cpp: In function 'int findEgg(int, vii)':
eastereggs.cpp:22:5: error: 'ck' was not declared in this scope
     ck.assign(n+1,1);
     ^~
eastereggs.cpp:22:5: note: suggested alternative: 'ok'
     ck.assign(n+1,1);
     ^~
     ok
eastereggs.cpp:33:12: error: 'query' was not declared in this scope
         if(query(qr)) {
            ^~~~~
eastereggs.cpp:49:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^