Submission #1042008

# Submission time Handle Problem Language Result Execution time Memory
1042008 2024-08-02T12:05:37 Z blackslex Easter Eggs (info1cup17_eastereggs) C++17
100 / 100
10 ms 600 KB
#include <bits/stdc++.h>
#include "grader.h"

using namespace std;
using pii = pair<int, int>;

int findEgg (int N, vector<pair<int, int>> bridges) {
    int n = N;
    vector<vector<int>> v(n + 5);
    for (auto &[x, y]: bridges) v[x].emplace_back(y), v[y].emplace_back(x);
    vector<int> ord;
    queue<int> q; q.emplace(1);
    vector<bool> f(n + 5);
    while (!q.empty()) {
        int cur = q.front(); q.pop();
        if (f[cur]) continue; f[cur] = 1; ord.emplace_back(cur);
        for (auto &e: v[cur]) q.emplace(e);
    }
    int l = 0, r = n - 1;
    while (l < r) {
        int mid = (l + r) >> 1;
        vector<int> ask(ord.begin(), ord.begin() + mid + 1);
        if (query(ask)) r = mid;
        else l = mid + 1;
    }
    return ord[l];
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:16:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   16 |         if (f[cur]) continue; f[cur] = 1; ord.emplace_back(cur);
      |         ^~
eastereggs.cpp:16:31: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   16 |         if (f[cur]) continue; f[cur] = 1; ord.emplace_back(cur);
      |                               ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Number of queries: 4
2 Correct 1 ms 344 KB Number of queries: 4
3 Correct 1 ms 344 KB Number of queries: 4
4 Correct 0 ms 344 KB Number of queries: 4
# Verdict Execution time Memory Grader output
1 Correct 3 ms 344 KB Number of queries: 8
2 Correct 7 ms 600 KB Number of queries: 9
3 Correct 9 ms 600 KB Number of queries: 9
4 Correct 8 ms 344 KB Number of queries: 9
# Verdict Execution time Memory Grader output
1 Correct 9 ms 344 KB Number of queries: 9
2 Correct 9 ms 344 KB Number of queries: 9
3 Correct 8 ms 512 KB Number of queries: 9
4 Correct 10 ms 500 KB Number of queries: 9