답안 #857412

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
857412 2023-10-06T07:18:45 Z chilinhxyzabc Easter Eggs (info1cup17_eastereggs) C++17
0 / 100
1 ms 692 KB
#include <bits/stdc++.h>
#define ll long long
#define infInt (int)1e9 + 1
// #define infLL 0x3f3f3f3f3f3f
#define infLL (int)1e17
#define vt vector<int>
#define vtt vector<vt>
#define vttt vector<vtt>
#define vtttt vector<vttt>
#define pii pair<int, int>
#define vpii vector<pii>
#define endl '\n'
#define all(a) a.begin(), a.end()
#define _sort(a) sort(all(a))
#define bsUp(a, x) upper_bound(all(a), x) - a.begin()
#define bsLow(a, x) lower_bound(all(a), x) - a.begin()
#define rev(a) reverse(all(a))
#define uni(vals) vals.resize(distance(vals.begin(), unique(all(vals))))
// #define int ll
// #define in(a); ; 
// #define hi ;
// #include "/home/phamngocthi/cp/see.cpp"
using namespace std;
 
vt st;
 
void dfs(int u, int p, vector<vector<int>> &adj) {
    st.push_back(u);
    for(int v : adj[u]) {
        if(v == p)
            continue;
        dfs(v, u, adj);
    }
}
 
int query(vector<int> islands);

vector<int> clone(vector<int> &a, int l, int r) {
    vector<int> res;
    for(int i = l; i <= r; i++)
        res.push_back(a[i]);
    return res;
}
 
int findEgg(int N, vector<pair<int,int>> bridges) {
    vector<vector<int>> adj(N, vector<int>());
    for(auto[u, v] : bridges) {
        u--, v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    st.clear();
    dfs(1, 0, adj);
    int l = 0, r = N - 1, res = N - 1;
    while(l <= r) {
        int m = (l + r) / 2;
        if(query(clone(st, 0, m))) {
            res = st[m];
            r = m - 1;
        } else {
            l = m + 1;
        }
    }
    return res + 1;
}
 
// signed main() {
//     ios_base::sync_with_stdio(false);cin.tie(NULL);
// }
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 692 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 456 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 504 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -