#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) {
pre[++timestamp] = x;
for(auto i : mp[x]) if(i != par) {
dfs(i, x);
}
}
int findEgg (int N, vector<pii> bridges) {
n = N, timestamp = 0;
mp.assign(n + 1, vector<int>());
qq.clear(), pre.assign(n + 1, 0);
for(auto i : bridges) {
mp[i.first].push_back(i.second);
mp[i.second].push_back(i.first);
}
dfs(1, 1);
int l = 0, r = timestamp;
while(r - l > 1) {
int mid = (l + r) / 2;
qq.clear();
rep(i, 1, mid) qq.push_back(pre[i]);
if(query(qq)) r = mid;
else l = mid;
}
return pre[r];
}
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 |
Correct |
1 ms |
200 KB |
Number of queries: 4 |
2 |
Correct |
2 ms |
200 KB |
Number of queries: 4 |
3 |
Correct |
1 ms |
200 KB |
Number of queries: 4 |
4 |
Correct |
1 ms |
200 KB |
Number of queries: 4 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
328 KB |
Number of queries: 8 |
2 |
Correct |
17 ms |
328 KB |
Number of queries: 9 |
3 |
Correct |
20 ms |
328 KB |
Number of queries: 9 |
4 |
Correct |
18 ms |
348 KB |
Number of queries: 9 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
21 ms |
356 KB |
Number of queries: 9 |
2 |
Correct |
18 ms |
340 KB |
Number of queries: 9 |
3 |
Correct |
19 ms |
336 KB |
Number of queries: 9 |
4 |
Correct |
20 ms |
336 KB |
Number of queries: 9 |