답안 #759725

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
759725 2023-06-16T16:18:03 Z jay_jayjay Easter Eggs (info1cup17_eastereggs) C++14
0 / 100
2 ms 476 KB
// {{{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]);
                int x=query(q);
                if(x) r=m;
                else l=m+1;
        }
        return ++l;
}
#undef DEBUG
#ifdef DEBUG
int main()
{
}
#endif

Compilation message

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);
      |                  ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 432 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 448 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 476 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -