답안 #909999

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
909999 2024-01-17T17:42:54 Z nasir_bashirov Easter Eggs (info1cup17_eastereggs) C++11
100 / 100
13 ms 1500 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
 
#define db long double
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define endl '\n'
#define all(x) x.begin(), x.end()
#define fastio\
    ios_base::sync_with_stdio(0);\
    cin.tie(0);\
    cout.tie(0)\
 
vi g[550], v;
int n;

void dfs(int node, int par){
    v.push_back(node);
    for(int i : g[node]){
        if(i == par)    continue;
        dfs(i, node);
    }
}

int findEgg(int N, vii bridges){
    n = N;
    for(int i = 1; i <= n; i++){
        g[i].clear();
    }
    for(pii i : bridges){
        g[i.first].push_back(i.second);
        g[i.second].push_back(i.first);
    }
    dfs(1, 1);
    int l = 0, r = n - 1, res = 0;
    while(l < r){
        int mid = (l + r) / 2;
        vi vv;
        for(int i = 0; i <= mid; i++)   vv.push_back(v[i]);
        if(query(vv)){
            res = mid;
            r = mid;
        }
        else{
            l = mid + 1;
        }
    }
    return v[l];
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:41:27: warning: variable 'res' set but not used [-Wunused-but-set-variable]
   41 |     int l = 0, r = n - 1, res = 0;
      |                           ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 452 KB Number of queries: 4
2 Correct 1 ms 452 KB Number of queries: 4
3 Correct 1 ms 448 KB Number of queries: 4
4 Correct 1 ms 448 KB Number of queries: 4
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 980 KB Number of queries: 8
2 Correct 8 ms 1008 KB Number of queries: 9
3 Correct 13 ms 776 KB Number of queries: 9
4 Correct 10 ms 740 KB Number of queries: 9
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 1056 KB Number of queries: 9
2 Correct 10 ms 1500 KB Number of queries: 9
3 Correct 13 ms 1072 KB Number of queries: 9
4 Correct 12 ms 1264 KB Number of queries: 9