Submission #389260

# Submission time Handle Problem Language Result Execution time Memory
389260 2021-04-14T01:46:56 Z i_am_noob Easter Eggs (info1cup17_eastereggs) C++17
40 / 100
1 ms 328 KB
#include<bits/stdc++.h>
#include "grader.h"
using namespace std;

#define ll long long
//#define int ll
#define rep(n) rep1(i,n)
#define rep1(i,n) rep2(i,0,n)
#define rep2(i,a,b) for(int i=a; i<(b); ++i)
#define rep3(i,a,b) for(int i=a; i>=(b); --i)
#define pb push_back
#define pii pair<int,int>
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define pow2(x) (1ll<<(x))

#ifdef i_am_noob
#define bug(...) cerr << "#" << __LINE__ << " " << #__VA_ARGS__ << "- ", _do(__VA_ARGS__)
template<typename T> void _do(T x){cerr << x << endl;}
template<typename T, typename ...S> void _do(T x, S... y){cerr << x << ", ";_do(y...);}
#else
#define bug(...) 49
#endif

const int maxn=605;

int cur;
bool alive[maxn],pick[maxn];
vector<int> adj[maxn],vec;

void dfs(int u, int tar){
    if(cur==tar) return;
    pick[u]=1;
    vec.pb(u+1);
    if(alive[u]) cur++;
    for(auto v: adj[u]) if(!pick[v]) dfs(v,tar);
}

int findEgg(int n, vector<pii> edges){
    rep(n) alive[i]=1,adj[i].clear();
    for(auto& [x,y]: edges) x--,y--;
    for(auto& [x,y]: edges) adj[x].pb(y),adj[y].pb(x);
    int tt=0;
    while(1){
        int x=0;
        rep(n) if(alive[i]) x++;
        bug(x);
        if(x==1){
            rep(n) if(alive[i]) return i+1;
        }
        vec.clear();
        memset(pick,0,sizeof pick);
        cur=0;
        dfs(0,x/2);
        int res=query(vec);
        for(auto i: vec) bug(i);
        rep(n) bug(i,pick[i]);
        bug(res);
        tt++;
        if(tt>5) exit(0);
        bug(alive[0]);
        if(res) rep(n) if(alive[i]&&!pick[i]) alive[i]=0,bug(i);
        if(!res) rep(n) if(alive[i]&&pick[i]) alive[i]=0;
    }
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:22:18: warning: statement has no effect [-Wunused-value]
   22 | #define bug(...) 49
      |                  ^~
eastereggs.cpp:47:9: note: in expansion of macro 'bug'
   47 |         bug(x);
      |         ^~~
eastereggs.cpp:22:18: warning: statement has no effect [-Wunused-value]
   22 | #define bug(...) 49
      |                  ^~
eastereggs.cpp:56:26: note: in expansion of macro 'bug'
   56 |         for(auto i: vec) bug(i);
      |                          ^~~
eastereggs.cpp:56:18: warning: unused variable 'i' [-Wunused-variable]
   56 |         for(auto i: vec) bug(i);
      |                  ^
eastereggs.cpp:22:18: warning: statement has no effect [-Wunused-value]
   22 | #define bug(...) 49
      |                  ^~
eastereggs.cpp:57:16: note: in expansion of macro 'bug'
   57 |         rep(n) bug(i,pick[i]);
      |                ^~~
eastereggs.cpp:22:18: warning: statement has no effect [-Wunused-value]
   22 | #define bug(...) 49
      |                  ^~
eastereggs.cpp:58:9: note: in expansion of macro 'bug'
   58 |         bug(res);
      |         ^~~
eastereggs.cpp:22:18: warning: statement has no effect [-Wunused-value]
   22 | #define bug(...) 49
      |                  ^~
eastereggs.cpp:61:9: note: in expansion of macro 'bug'
   61 |         bug(alive[0]);
      |         ^~~
eastereggs.cpp:62:64: warning: right operand of comma operator has no effect [-Wunused-value]
   62 |         if(res) rep(n) if(alive[i]&&!pick[i]) alive[i]=0,bug(i);
      |                                                                ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Number of queries: 4
2 Correct 1 ms 200 KB Number of queries: 4
3 Correct 1 ms 200 KB Number of queries: 4
4 Correct 1 ms 200 KB Number of queries: 4
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 200 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 328 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -