//
#ifndef __SIZEOF_INT128__
#define __SIZEOF_INT128__
#endif
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include "highway.h"
using namespace std;
using namespace chrono;
using namespace __gnu_pbds;
template <typename T> using oset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define rep(i, p, k) for(int i(p); i < (k); ++i)
#define per(i, p, k) for(int i(p); i > (k); --i)
#define sz(x) (int)(x).size()
#define sc static_cast
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef __int128_t lll;
//#define int ll
template <typename T = int> using par = std::pair <T, T>;
#define fi first
#define se second
#define test int _number_of_tests(in()); while(_number_of_tests--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb emplace_back
struct Timer {
string name{""};
time_point<high_resolution_clock> end, start{high_resolution_clock::now()};
duration<float, std::milli> dur;
Timer() = default;
Timer(string nm): name(nm) {}
~Timer() {
end = high_resolution_clock::now(); dur= end - start;
cout << "@" << name << "> " << dur.count() << " ms" << '\n';
}
};
template <typename T = int> inline T in()
{
static T x;
std::cin >> x;
return x;
}
std::string yn(bool b)
{
if(b) return "YES\n";
else return "NO\n";
}
template <typename F, typename S> std::ostream& operator<<(std::ostream& out, const std::pair <F, S>& par);
template <typename T> std::ostream& operator<< (std::ostream& out, const std::vector <T>& wek)
{
for(const auto& i : wek)out << i << ' ';
return out;
}
template <typename F, typename S> std::ostream& operator<<(std::ostream& out, const std::pair <F, S>& par)
{
out << '{'<<par.first<<", "<<par.second<<"}";
return out;
}
#define show(x) cerr << #x << " = " << x << '\n';
constexpr int maxn = 90003;
vector <pair<int, int>> graf[maxn];
bool byl[maxn];
void find_pair(int n, vector <int> ka, vector <int> kb, int a, int b)
{
int m(sz(ka));
rep(i, 0, m){
graf[ka[i]].pb(kb[i], i);
graf[kb[i]].pb(ka[i], i);
}
ll d(ask(vector<int>(m, 0))/a);
int p(0), k(m), s;
vector <int> sk(m);
while(k > p){
s = (p+k+1)/2;
rep(i, 0, m)sk[i] = i >= s;
if(ask(sk) > d*a)p = s;
else k = s-1;
}
vector <pair <int, int>> kr[2]{{{p, ka[p]}}, {{p, kb[p]}}};
queue <pair <int, bool>> kul;
kul.push({ka[p], 0});
kul.push({kb[p], 1});
byl[ka[p]] = byl[kb[p]] = 1;
while(kul.size()){
auto [w, b] = kul.front(); kul.pop();
for(auto [i, j]: graf[w])if(!byl[i]){
byl[i] = 1;
kr[b].pb(j, i);
kul.push({i, b});
}
}
int t[2];
rep(b, 0, 2){
int p(0), k(sz(kr[b])-1), s;
while(k > p){
s = (p+k+1)/2;
rep(i, 0, m)sk[i] = 1;
rep(i, 0, sz(kr[!b]))sk[kr[!b][i].first] = 0;
rep(i, 0, s)sk[kr[b][i].first] = 0;
if(ask(sk) == d*a)k = s-1;
else p = s;
}
t[b] = kr[b][p].second;
}
answer(t[0], t[1]);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2392 KB |
Output is correct |
3 |
Correct |
1 ms |
2392 KB |
Output is correct |
4 |
Correct |
1 ms |
2392 KB |
Output is correct |
5 |
Correct |
1 ms |
2392 KB |
Output is correct |
6 |
Correct |
1 ms |
2392 KB |
Output is correct |
7 |
Correct |
1 ms |
2392 KB |
Output is correct |
8 |
Correct |
1 ms |
2392 KB |
Output is correct |
9 |
Correct |
1 ms |
2392 KB |
Output is correct |
10 |
Correct |
1 ms |
2392 KB |
Output is correct |
11 |
Correct |
1 ms |
2532 KB |
Output is correct |
12 |
Correct |
2 ms |
2392 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2392 KB |
Output is correct |
2 |
Correct |
8 ms |
3160 KB |
Output is correct |
3 |
Correct |
85 ms |
9444 KB |
Output is correct |
4 |
Correct |
93 ms |
9212 KB |
Output is correct |
5 |
Correct |
76 ms |
9192 KB |
Output is correct |
6 |
Correct |
76 ms |
9188 KB |
Output is correct |
7 |
Correct |
73 ms |
9188 KB |
Output is correct |
8 |
Correct |
76 ms |
9284 KB |
Output is correct |
9 |
Correct |
75 ms |
9136 KB |
Output is correct |
10 |
Correct |
89 ms |
9188 KB |
Output is correct |
11 |
Correct |
84 ms |
8708 KB |
Output is correct |
12 |
Correct |
85 ms |
8920 KB |
Output is correct |
13 |
Correct |
76 ms |
8664 KB |
Output is correct |
14 |
Correct |
77 ms |
8668 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
3160 KB |
Output is correct |
2 |
Correct |
15 ms |
3872 KB |
Output is correct |
3 |
Correct |
22 ms |
4428 KB |
Output is correct |
4 |
Correct |
67 ms |
8472 KB |
Output is correct |
5 |
Correct |
71 ms |
8596 KB |
Output is correct |
6 |
Correct |
71 ms |
8628 KB |
Output is correct |
7 |
Correct |
80 ms |
8772 KB |
Output is correct |
8 |
Correct |
80 ms |
8528 KB |
Output is correct |
9 |
Correct |
68 ms |
8968 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2392 KB |
Output is correct |
2 |
Correct |
9 ms |
3140 KB |
Output is correct |
3 |
Correct |
53 ms |
7624 KB |
Output is correct |
4 |
Correct |
89 ms |
9204 KB |
Output is correct |
5 |
Correct |
70 ms |
9276 KB |
Output is correct |
6 |
Correct |
65 ms |
9196 KB |
Output is correct |
7 |
Correct |
68 ms |
9240 KB |
Output is correct |
8 |
Correct |
90 ms |
9272 KB |
Output is correct |
9 |
Correct |
84 ms |
9112 KB |
Output is correct |
10 |
Correct |
78 ms |
9196 KB |
Output is correct |
11 |
Correct |
85 ms |
8668 KB |
Output is correct |
12 |
Correct |
80 ms |
8760 KB |
Output is correct |
13 |
Correct |
93 ms |
8556 KB |
Output is correct |
14 |
Correct |
83 ms |
8348 KB |
Output is correct |
15 |
Correct |
70 ms |
9176 KB |
Output is correct |
16 |
Correct |
72 ms |
9176 KB |
Output is correct |
17 |
Correct |
83 ms |
8776 KB |
Output is correct |
18 |
Correct |
76 ms |
8660 KB |
Output is correct |
19 |
Correct |
85 ms |
9148 KB |
Output is correct |
20 |
Correct |
77 ms |
8668 KB |
Output is correct |
21 |
Correct |
65 ms |
9708 KB |
Output is correct |
22 |
Correct |
60 ms |
9684 KB |
Output is correct |
23 |
Correct |
76 ms |
9248 KB |
Output is correct |
24 |
Correct |
74 ms |
9172 KB |
Output is correct |
25 |
Correct |
84 ms |
8768 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
3164 KB |
Output is correct |
2 |
Correct |
10 ms |
3408 KB |
Output is correct |
3 |
Correct |
103 ms |
9584 KB |
Output is correct |
4 |
Correct |
99 ms |
9996 KB |
Output is correct |
5 |
Correct |
145 ms |
10928 KB |
Output is correct |
6 |
Correct |
136 ms |
10944 KB |
Output is correct |
7 |
Correct |
120 ms |
11052 KB |
Output is correct |
8 |
Correct |
127 ms |
10628 KB |
Output is correct |
9 |
Correct |
84 ms |
8512 KB |
Output is correct |
10 |
Correct |
92 ms |
9136 KB |
Output is correct |
11 |
Correct |
92 ms |
9400 KB |
Output is correct |
12 |
Correct |
118 ms |
10552 KB |
Output is correct |
13 |
Correct |
129 ms |
10832 KB |
Output is correct |
14 |
Correct |
147 ms |
10748 KB |
Output is correct |
15 |
Correct |
120 ms |
11256 KB |
Output is correct |
16 |
Correct |
112 ms |
9724 KB |
Output is correct |
17 |
Correct |
77 ms |
9656 KB |
Output is correct |
18 |
Correct |
83 ms |
9684 KB |
Output is correct |
19 |
Correct |
78 ms |
9544 KB |
Output is correct |
20 |
Correct |
77 ms |
9668 KB |
Output is correct |
21 |
Correct |
119 ms |
11212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
3160 KB |
Output is correct |
2 |
Correct |
9 ms |
3416 KB |
Output is correct |
3 |
Correct |
84 ms |
9644 KB |
Output is correct |
4 |
Correct |
111 ms |
9768 KB |
Output is correct |
5 |
Correct |
99 ms |
9848 KB |
Output is correct |
6 |
Correct |
112 ms |
10904 KB |
Output is correct |
7 |
Correct |
90 ms |
9640 KB |
Output is correct |
8 |
Correct |
106 ms |
9700 KB |
Output is correct |
9 |
Correct |
102 ms |
9856 KB |
Output is correct |
10 |
Correct |
117 ms |
10792 KB |
Output is correct |
11 |
Correct |
122 ms |
10940 KB |
Output is correct |
12 |
Correct |
114 ms |
11044 KB |
Output is correct |
13 |
Correct |
94 ms |
9396 KB |
Output is correct |
14 |
Correct |
89 ms |
9004 KB |
Output is correct |
15 |
Correct |
95 ms |
9504 KB |
Output is correct |
16 |
Correct |
85 ms |
9000 KB |
Output is correct |
17 |
Correct |
102 ms |
9640 KB |
Output is correct |
18 |
Correct |
93 ms |
9056 KB |
Output is correct |
19 |
Correct |
123 ms |
10568 KB |
Output is correct |
20 |
Correct |
124 ms |
10720 KB |
Output is correct |
21 |
Correct |
122 ms |
11160 KB |
Output is correct |
22 |
Correct |
151 ms |
11100 KB |
Output is correct |
23 |
Correct |
123 ms |
10944 KB |
Output is correct |
24 |
Correct |
116 ms |
11020 KB |
Output is correct |
25 |
Correct |
120 ms |
10968 KB |
Output is correct |
26 |
Correct |
146 ms |
11004 KB |
Output is correct |
27 |
Correct |
74 ms |
9572 KB |
Output is correct |
28 |
Correct |
77 ms |
9452 KB |
Output is correct |
29 |
Correct |
81 ms |
9728 KB |
Output is correct |
30 |
Correct |
76 ms |
9672 KB |
Output is correct |
31 |
Correct |
77 ms |
9532 KB |
Output is correct |
32 |
Correct |
76 ms |
9564 KB |
Output is correct |
33 |
Correct |
77 ms |
9756 KB |
Output is correct |
34 |
Correct |
76 ms |
9612 KB |
Output is correct |
35 |
Correct |
74 ms |
9540 KB |
Output is correct |
36 |
Correct |
76 ms |
9380 KB |
Output is correct |
37 |
Correct |
76 ms |
9612 KB |
Output is correct |
38 |
Correct |
80 ms |
9640 KB |
Output is correct |
39 |
Correct |
121 ms |
11312 KB |
Output is correct |
40 |
Correct |
121 ms |
11308 KB |
Output is correct |
41 |
Correct |
141 ms |
11124 KB |
Output is correct |
42 |
Correct |
116 ms |
10736 KB |
Output is correct |