제출 #759727

#제출 시각아이디문제언어결과실행 시간메모리
759727jay_jayjayEaster Eggs (info1cup17_eastereggs)C++14
100 / 100
30 ms360 KiB
// {{{1
extern "C" int __lsan_is_turned_off() { return 1; }
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <iostream>
#include <deque>
using namespace std;

#define ll long long
#define inf 0x3f3f3f3f
#define infl 0x3f3f3f3f3f3f3f3f

#ifdef DEBUG
#define dprintf(args...) fprintf(stderr,args)
#include <assert.h>
#endif
#ifndef DEBUG
#define dprintf(args...) 69
#define assert(args...) 42
#endif
// 1}}}
// pain im still so stupid

int query(vector<int> islands);

int findEgg(int n, vector<pair<int,int>> edges) {
        for(auto&[a,b]:edges)a--,b--;

        vector<vector<int>> adj(n);
        for(auto [a,b]:edges) adj[a].push_back(b),adj[b].push_back(a);

        vector<int> po;
        auto dfs = [&](auto& self, int u, int p=-1) -> void {
                po.push_back(u);
                for(auto v:adj[u])if(v!=p)self(self,v,u);
        };
        dfs(dfs,0,0);

        vector<int> q;
        int l=0,r=n-1;
        while(l<r) {
                int m=l+(r-l)/2;
                //printf("%d %d %d\n",l,m,r);
                q.clear();
                for(int i=0;i<=m;i++)
                        q.push_back(1+po[i])
                                //,printf("%d ",po[i])
                                ;
                //printf("\n");
                int x=query(q);
                if(x) r=m;
                else l=m+1;
        }
        return ++po[l];
}
#undef DEBUG
#ifdef DEBUG
int main()
{
}
#endif

컴파일 시 표준 에러 (stderr) 메시지

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:34:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   34 |         for(auto&[a,b]:edges)a--,b--;
      |                  ^
eastereggs.cpp:37:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   37 |         for(auto [a,b]:edges) adj[a].push_back(b),adj[b].push_back(a);
      |                  ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...