Submission #703958

# Submission time Handle Problem Language Result Execution time Memory
703958 2023-03-01T06:10:17 Z boyliguanhan Easter Eggs (info1cup17_eastereggs) C++17
100 / 100
22 ms 464 KB
#include "grader.h"

using namespace std;
vector<int> order;
vector<int> adj[513];
void dfs(int n, int p) {
    order.push_back(n);
    for (auto i : adj[n])
        if (i != p)
            dfs(i, n);
}
int findEgg(int N, vector < pair < int, int > > bridges)
{
    order.clear();
    for (int i = 1; i <= N; i++)
        adj[i].clear();
    for (auto i : bridges)
        adj[i.first].push_back(i.second), adj[i.second].push_back(i.first);
    dfs(1, 0);
    int l = 1, r = N;
    while (l < r) {
        int mid = l + r >> 1;
        if (query(vector<int>(order.begin(), order.begin() + mid)))
            r = mid;
        else
            l = mid + 1;
    }
    return order[l - 1];
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:22:21: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   22 |         int mid = l + r >> 1;
      |                   ~~^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Number of queries: 4
2 Correct 1 ms 208 KB Number of queries: 4
3 Correct 1 ms 208 KB Number of queries: 4
4 Correct 1 ms 208 KB Number of queries: 4
# Verdict Execution time Memory Grader output
1 Correct 5 ms 336 KB Number of queries: 8
2 Correct 11 ms 336 KB Number of queries: 9
3 Correct 15 ms 352 KB Number of queries: 9
4 Correct 14 ms 344 KB Number of queries: 9
# Verdict Execution time Memory Grader output
1 Correct 22 ms 356 KB Number of queries: 9
2 Correct 15 ms 464 KB Number of queries: 9
3 Correct 17 ms 464 KB Number of queries: 9
4 Correct 16 ms 396 KB Number of queries: 9