#include "grader.h"
#define wiwihorz
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma loop-opt(on)
#define rep(i, a, b) for(int i = a; i <= b; i ++)
#define rrep(i, a, b) for(int i = b; i >= a; i--)
#define all(x) x.begin(), x.end()
#define ceil(a, b) ((a + b - 1) / (b))
#define INF 1000000000000000000
#define MOD 1000000007
#define eps (1e-9)
using namespace std;
#define lld long double
#define pii pair<int, int>
#define random mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count())
#ifdef wiwihorz
#define print(a...) kout("[" + string(#a) + "] = ", a)
void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
void kout() { cerr << endl; }
template<class T1, class ... T2> void kout(T1 a, T2 ... e) { cerr << a << " ", kout(e...); }
#else
#define print(...) 0
#define vprint(...) 0
#endif
int n, timestamp = 0;
vector<vector<int>> mp;
vector<int> qq, pre;
void dfs(int x, int par) {
if(x != par && mp[x].size() == 1)pre[++timestamp] = x;
for(auto i : mp[x]) if(i != par) {
dfs(i, x);
pre[++timestamp] = x;
}
}
int findEgg (int N, vector<pii> bridges) {
n = N, timestamp = 0;
mp.assign(n + 1, vector<int>());
qq.clear(), pre.assign(2 * n, 0);
for(auto i : bridges) {
mp[i.first].push_back(i.second);
mp[i.second].push_back(i.first);
}
dfs(1, 1);
int l = 1, r = timestamp + 1;
while(r - l > 1) {
int mid = (l + r) / 2;
qq.clear();
rep(i, mid, r - 1) qq.push_back(pre[i]);
sort(all(qq)), qq.resize(unique(all(qq)) - qq.begin());
if(query(qq)) l = mid;
else r = mid;
}
return pre[l];
}
Compilation message
eastereggs.cpp:5: warning: ignoring '#pragma loop ' [-Wunknown-pragmas]
5 | #pragma loop-opt(on)
|
eastereggs.cpp:24:13: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
24 | void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
| ^~~~
eastereggs.cpp:24:21: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
24 | void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
1 ms |
200 KB |
Number of queries: 5 |
2 |
Runtime error |
1 ms |
456 KB |
Execution killed with signal 6 |
3 |
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 |
2 ms |
456 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |