답안 #723986

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
723986 2023-04-14T14:54:35 Z stevancv Easter Eggs (info1cup17_eastereggs) C++14
87 / 100
24 ms 456 KB
#include <bits/stdc++.h>
#include "grader.h"
#define ll long long
#define ld long double
#define sp ' '
#define en '\n'
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
using namespace std;
const int N = 600 + 2;
const int inf = 1e9;
vector<int> g[N], order;
void Dfs(int s, int e) {
    order.push_back(s);
    for (int u : g[s]) {
        if (u != e) Dfs(u, s);
    }
}
int findEgg(int n, vector<pair<int, int>> e) {
    order.clear();
    for (int i = 1; i <= n; i++) g[i].clear();
    for (auto u : e) {
        g[u.first].push_back(u.second);
        g[u.second].push_back(u.first);
    }
    Dfs(1, 0);
    int l = 0, r = n - 1, ans = n - 1;
    while (l <= r) {
        int mid = l + r >> 1;
        vector<int> t;
        for (int i = 0; i <= mid; i++) t.push_back(order[i]);
        if (query(t)) {
            ans = mid;
            r = mid - 1;
        }
        else l = mid + 1;
    }
    return order[ans];
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:29:21: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   29 |         int mid = l + r >> 1;
      |                   ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Partially correct 1 ms 208 KB Number of queries: 5
2 Partially correct 2 ms 292 KB Number of queries: 5
3 Partially correct 1 ms 208 KB Number of queries: 5
4 Partially correct 1 ms 208 KB Number of queries: 5
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 352 KB Number of queries: 9
2 Correct 10 ms 336 KB Number of queries: 9
3 Correct 17 ms 456 KB Number of queries: 9
4 Correct 14 ms 344 KB Number of queries: 9
# 결과 실행 시간 메모리 Grader output
1 Partially correct 24 ms 360 KB Number of queries: 10
2 Correct 17 ms 336 KB Number of queries: 9
3 Partially correct 15 ms 356 KB Number of queries: 10
4 Partially correct 19 ms 360 KB Number of queries: 10