답안 #471004

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
471004 2021-09-06T15:19:25 Z vishesh312 Easter Eggs (info1cup17_eastereggs) C++17
87 / 100
27 ms 480 KB
#include "bits/stdc++.h"
#include "grader.h"
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
*/

#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define sz(x) (int)(x).size()

using ll = long long;
const int mod = 1e9+7;

void dfs(int u, int p, vector<vector<int>> &adj, vector<int> &o) {
    o.push_back(u);
    for (int v : adj[u])
        if (v != p)
            dfs(v, u, adj, o);
}

int findEgg(int n, vector<pair<int, int>> bridges) {
    vector<vector<int>> adj(n+1);
    vector<int> o;
    for (auto [u, v] : bridges) {
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    dfs(1, -1, adj, o);
    int l = 0, r = n;
    auto chk = [&] (int m) -> bool {
        vector<int> v(o.begin(), o.begin() + m + 1);
/*      for (int x : v)
            cout << x << " ";
        cout << '\n';
*/      return query(v);
    };
    while (l < r) {
        int m = (l + r) / 2;
//      cout << "m : " << m << '\n';
        if (chk(m)) {
//          cerr << "true\n";
            r = m;
        } else {
//          cout << "false\n";
            l = m+1;
        }
    }
//  cout << r << " " << o[r] << '\n';
    return o[r];
}
# 결과 실행 시간 메모리 Grader output
1 Partially correct 1 ms 200 KB Number of queries: 5
2 Partially correct 2 ms 200 KB Number of queries: 5
3 Partially correct 2 ms 200 KB Number of queries: 5
4 Partially correct 1 ms 200 KB Number of queries: 5
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 352 KB Number of queries: 8
2 Correct 15 ms 328 KB Number of queries: 9
3 Correct 21 ms 348 KB Number of queries: 9
4 Correct 27 ms 480 KB Number of queries: 9
# 결과 실행 시간 메모리 Grader output
1 Partially correct 23 ms 380 KB Number of queries: 10
2 Correct 21 ms 360 KB Number of queries: 9
3 Partially correct 21 ms 348 KB Number of queries: 10
4 Partially correct 19 ms 328 KB Number of queries: 10