//
#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);
auto pyt = [n,m](vector <bool> v){
vector <int> w(m);
rep(i, 0, n)if(v[i])for(auto [i, j]: graf[i])w[j] |= 1;
return ask(w);
};
int p(0), k(n), s;
vector <bool> v(n);
while(k > p){
s = (p+k)/2;
rep(i, 0, n)v[i] = i >= s;
if(pyt(v) == d*a)k = s;
else p = s+1;
}
int r(p-1);
vector <int> so;
queue <int> kul;
bool je(0);
rp:
rep(i, 0, n)byl[i] = 0;
so = {r};
kul.push(r);
byl[r] = 1;
while(kul.size()){
auto t(kul.front()); kul.pop();
for(auto [i, j]: graf[t])if(!byl[i]){
kul.push(i);
so.pb(i);
byl[i] = 1;
}
}
p = 0, k = n;
while(k > p){
s = (p+k)/2;
rep(i, 0, n)v[so[i]] = i >= s;
if(pyt(v) == d*a)k = s;
else p = s+1;
}
if(!je){
r = so[p-1];
je = 1;
goto rp;
}
answer(r, so[p-1]);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
2 ms |
2392 KB |
Output is correct |
3 |
Correct |
1 ms |
2428 KB |
Output is correct |
4 |
Correct |
2 ms |
2392 KB |
Output is correct |
5 |
Correct |
1 ms |
2388 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 |
2392 KB |
Output is correct |
12 |
Correct |
1 ms |
2392 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
13 ms |
3220 KB |
Output is correct |
3 |
Correct |
136 ms |
8296 KB |
Output is correct |
4 |
Correct |
122 ms |
8284 KB |
Output is correct |
5 |
Correct |
137 ms |
8288 KB |
Output is correct |
6 |
Correct |
103 ms |
8296 KB |
Output is correct |
7 |
Correct |
140 ms |
8288 KB |
Output is correct |
8 |
Correct |
114 ms |
8296 KB |
Output is correct |
9 |
Correct |
107 ms |
8288 KB |
Output is correct |
10 |
Correct |
112 ms |
8288 KB |
Output is correct |
11 |
Correct |
114 ms |
7748 KB |
Output is correct |
12 |
Correct |
130 ms |
7908 KB |
Output is correct |
13 |
Correct |
117 ms |
7736 KB |
Output is correct |
14 |
Correct |
113 ms |
7920 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
3160 KB |
Output is correct |
2 |
Correct |
18 ms |
3652 KB |
Output is correct |
3 |
Correct |
31 ms |
4336 KB |
Output is correct |
4 |
Correct |
76 ms |
7908 KB |
Output is correct |
5 |
Correct |
73 ms |
7744 KB |
Output is correct |
6 |
Correct |
75 ms |
7736 KB |
Output is correct |
7 |
Correct |
79 ms |
7896 KB |
Output is correct |
8 |
Correct |
77 ms |
7732 KB |
Output is correct |
9 |
Correct |
84 ms |
7744 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2392 KB |
Output is correct |
2 |
Correct |
11 ms |
3196 KB |
Output is correct |
3 |
Correct |
81 ms |
7076 KB |
Output is correct |
4 |
Correct |
108 ms |
8288 KB |
Output is correct |
5 |
Correct |
116 ms |
8300 KB |
Output is correct |
6 |
Correct |
123 ms |
8320 KB |
Output is correct |
7 |
Correct |
110 ms |
8300 KB |
Output is correct |
8 |
Correct |
126 ms |
8288 KB |
Output is correct |
9 |
Correct |
110 ms |
8344 KB |
Output is correct |
10 |
Correct |
121 ms |
8292 KB |
Output is correct |
11 |
Correct |
110 ms |
7740 KB |
Output is correct |
12 |
Correct |
98 ms |
7736 KB |
Output is correct |
13 |
Correct |
111 ms |
7800 KB |
Output is correct |
14 |
Correct |
118 ms |
7744 KB |
Output is correct |
15 |
Correct |
110 ms |
8296 KB |
Output is correct |
16 |
Correct |
112 ms |
8300 KB |
Output is correct |
17 |
Correct |
111 ms |
7740 KB |
Output is correct |
18 |
Correct |
117 ms |
7888 KB |
Output is correct |
19 |
Correct |
113 ms |
8296 KB |
Output is correct |
20 |
Correct |
95 ms |
7744 KB |
Output is correct |
21 |
Correct |
94 ms |
9088 KB |
Output is correct |
22 |
Correct |
102 ms |
8876 KB |
Output is correct |
23 |
Correct |
105 ms |
8460 KB |
Output is correct |
24 |
Correct |
87 ms |
8444 KB |
Output is correct |
25 |
Correct |
99 ms |
7828 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
3208 KB |
Output is correct |
2 |
Correct |
13 ms |
3160 KB |
Output is correct |
3 |
Correct |
136 ms |
8588 KB |
Output is correct |
4 |
Correct |
161 ms |
9188 KB |
Output is correct |
5 |
Correct |
175 ms |
9972 KB |
Output is correct |
6 |
Correct |
189 ms |
9960 KB |
Output is correct |
7 |
Correct |
176 ms |
10368 KB |
Output is correct |
8 |
Correct |
177 ms |
9976 KB |
Output is correct |
9 |
Correct |
112 ms |
8260 KB |
Output is correct |
10 |
Correct |
109 ms |
8780 KB |
Output is correct |
11 |
Correct |
120 ms |
9256 KB |
Output is correct |
12 |
Correct |
142 ms |
9684 KB |
Output is correct |
13 |
Correct |
157 ms |
9992 KB |
Output is correct |
14 |
Correct |
137 ms |
9956 KB |
Output is correct |
15 |
Correct |
170 ms |
9964 KB |
Output is correct |
16 |
Correct |
125 ms |
9452 KB |
Output is correct |
17 |
Correct |
98 ms |
8792 KB |
Output is correct |
18 |
Correct |
99 ms |
8900 KB |
Output is correct |
19 |
Correct |
86 ms |
8812 KB |
Output is correct |
20 |
Correct |
107 ms |
8900 KB |
Output is correct |
21 |
Correct |
149 ms |
9956 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
3160 KB |
Output is correct |
2 |
Correct |
12 ms |
3160 KB |
Output is correct |
3 |
Partially correct |
143 ms |
8872 KB |
Output is partially correct |
4 |
Correct |
131 ms |
8788 KB |
Output is correct |
5 |
Partially correct |
137 ms |
9248 KB |
Output is partially correct |
6 |
Correct |
159 ms |
9960 KB |
Output is correct |
7 |
Partially correct |
140 ms |
8624 KB |
Output is partially correct |
8 |
Correct |
133 ms |
8780 KB |
Output is correct |
9 |
Correct |
142 ms |
9024 KB |
Output is correct |
10 |
Partially correct |
172 ms |
10092 KB |
Output is partially correct |
11 |
Partially correct |
178 ms |
10208 KB |
Output is partially correct |
12 |
Partially correct |
196 ms |
10256 KB |
Output is partially correct |
13 |
Correct |
127 ms |
9052 KB |
Output is correct |
14 |
Correct |
87 ms |
8764 KB |
Output is correct |
15 |
Correct |
124 ms |
9064 KB |
Output is correct |
16 |
Correct |
112 ms |
8780 KB |
Output is correct |
17 |
Correct |
126 ms |
9220 KB |
Output is correct |
18 |
Correct |
117 ms |
8832 KB |
Output is correct |
19 |
Correct |
139 ms |
9664 KB |
Output is correct |
20 |
Partially correct |
155 ms |
9844 KB |
Output is partially correct |
21 |
Partially correct |
175 ms |
10232 KB |
Output is partially correct |
22 |
Partially correct |
153 ms |
10024 KB |
Output is partially correct |
23 |
Correct |
148 ms |
9968 KB |
Output is correct |
24 |
Partially correct |
173 ms |
10212 KB |
Output is partially correct |
25 |
Partially correct |
146 ms |
9980 KB |
Output is partially correct |
26 |
Correct |
159 ms |
9980 KB |
Output is correct |
27 |
Correct |
98 ms |
8856 KB |
Output is correct |
28 |
Partially correct |
100 ms |
8820 KB |
Output is partially correct |
29 |
Partially correct |
100 ms |
8988 KB |
Output is partially correct |
30 |
Correct |
98 ms |
8876 KB |
Output is correct |
31 |
Correct |
103 ms |
8812 KB |
Output is correct |
32 |
Partially correct |
111 ms |
8720 KB |
Output is partially correct |
33 |
Correct |
101 ms |
8972 KB |
Output is correct |
34 |
Correct |
96 ms |
8812 KB |
Output is correct |
35 |
Partially correct |
91 ms |
8800 KB |
Output is partially correct |
36 |
Partially correct |
94 ms |
8704 KB |
Output is partially correct |
37 |
Correct |
102 ms |
8904 KB |
Output is correct |
38 |
Partially correct |
109 ms |
9272 KB |
Output is partially correct |
39 |
Correct |
155 ms |
9972 KB |
Output is correct |
40 |
Correct |
153 ms |
10196 KB |
Output is correct |
41 |
Correct |
141 ms |
9948 KB |
Output is correct |
42 |
Correct |
151 ms |
9956 KB |
Output is correct |