#include "highway.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll linf = ll(1e18);
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> p2;
#define rep(i, high) for (int i = 0; i < high; i++)
#define repp(i, low, high) for (int i = low; i < high; i++)
#define repe(i, container) for (auto& i : container)
#define sz(container) ((int)container.size())
#define all(x) begin(x),end(x)
#if _LOCAL
#define assert(x) if (!(x)) __debugbreak()
#endif
typedef long long ll;
void dfs(int u, int p, int v, int d, int sign, vector<vector<p2>>&edges, vi& edgedist, vi& nodedist)
{
nodedist[u] = d;
repe(e, edges[u])
{
if (e.first == p) continue;
edgedist[e.second] = d*sign * (e.first == v ? -1 : 1);
dfs(e.first, u, v, d + 1, sign * (e.first==v?-1:1), edges, edgedist, nodedist);
}
}
void find_pair(int n, std::vector<int> U, std::vector<int> V, int A, int B)
{
int m = sz(U);
ll baseline = ask(vi(m, 0));
int lo = -1;
int hi = m;
while (lo+1<hi)
{
int mid = (lo + hi) / 2;
vi w(m);
rep(i, mid + 1) w[i] = 1;
if (ask(w) > baseline)
{
hi = mid;
}
else lo = mid;
}
int u = U[hi];
int v = V[hi];
vector<vector<p2>> edges(n);
rep(i, m)
{
int a = U[i];
int b = V[i];
edges[a].emplace_back(b, i);
edges[b].emplace_back(a, i);
}
vi ans;
rep(_, 2)
{
vi istree(m);
vi edgedist(m);
vi nodedist(n);
queue<tuple<int,int,int>> q;
vi vis(n);
q.emplace(u, 1, -1);
while (sz(q))
{
int a, d, s;
tie(a, d, s) = q.front();
q.pop();
nodedist[a] = d;
repe(e, edges[a])
{
if (vis[e.first])
{
//
}
else
{
vis[e.first] = 1;
istree[e.second] = 1;
edgedist[e.second] = d * s * (e.first == v ? -1 : 1);
q.emplace(e.first, d + 1, s * (e.first == v ? -1 : 1));
}
}
}
nodedist[u] = -int(1e6);
vector<p2> edge_order;
rep(i, m) edge_order.emplace_back(edgedist[i], i);
sort(edge_order.rbegin(), edge_order.rend());
lo = -1;
hi = m;
while (lo+1<hi)
{
int mid = (lo + hi) / 2;
vi w(m);
rep(i, mid + 1) w[edge_order[i].second] = 1;
if (ask(w) > baseline)
{
hi = mid;
}
else lo = mid;
}
int e = edge_order[hi].second;
ans.push_back(nodedist[U[e]]>nodedist[V[e]]?U[e]:V[e]);
swap(u, v);
}
answer(ans[0], ans[1]);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
12 ms |
1592 KB |
Output is correct |
3 |
Correct |
102 ms |
10556 KB |
Output is correct |
4 |
Correct |
106 ms |
10572 KB |
Output is correct |
5 |
Correct |
105 ms |
10700 KB |
Output is correct |
6 |
Correct |
117 ms |
10548 KB |
Output is correct |
7 |
Correct |
107 ms |
10544 KB |
Output is correct |
8 |
Correct |
101 ms |
10692 KB |
Output is correct |
9 |
Correct |
108 ms |
10560 KB |
Output is correct |
10 |
Correct |
104 ms |
10556 KB |
Output is correct |
11 |
Correct |
105 ms |
10156 KB |
Output is correct |
12 |
Correct |
113 ms |
10020 KB |
Output is correct |
13 |
Correct |
103 ms |
9928 KB |
Output is correct |
14 |
Correct |
103 ms |
9928 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
1532 KB |
Output is correct |
2 |
Correct |
14 ms |
2500 KB |
Output is correct |
3 |
Correct |
24 ms |
3688 KB |
Output is correct |
4 |
Correct |
71 ms |
9816 KB |
Output is correct |
5 |
Correct |
80 ms |
9760 KB |
Output is correct |
6 |
Correct |
68 ms |
9924 KB |
Output is correct |
7 |
Correct |
72 ms |
9920 KB |
Output is correct |
8 |
Correct |
70 ms |
10056 KB |
Output is correct |
9 |
Correct |
73 ms |
10148 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
14 ms |
1528 KB |
Output is correct |
3 |
Correct |
79 ms |
8872 KB |
Output is correct |
4 |
Correct |
99 ms |
10428 KB |
Output is correct |
5 |
Correct |
94 ms |
10564 KB |
Output is correct |
6 |
Correct |
95 ms |
10740 KB |
Output is correct |
7 |
Correct |
94 ms |
10804 KB |
Output is correct |
8 |
Correct |
96 ms |
10508 KB |
Output is correct |
9 |
Correct |
128 ms |
10384 KB |
Output is correct |
10 |
Correct |
113 ms |
10548 KB |
Output is correct |
11 |
Correct |
107 ms |
10316 KB |
Output is correct |
12 |
Correct |
109 ms |
9792 KB |
Output is correct |
13 |
Correct |
112 ms |
10152 KB |
Output is correct |
14 |
Correct |
108 ms |
9908 KB |
Output is correct |
15 |
Correct |
104 ms |
10388 KB |
Output is correct |
16 |
Correct |
113 ms |
10596 KB |
Output is correct |
17 |
Correct |
102 ms |
9920 KB |
Output is correct |
18 |
Correct |
107 ms |
9920 KB |
Output is correct |
19 |
Correct |
114 ms |
10568 KB |
Output is correct |
20 |
Correct |
93 ms |
10004 KB |
Output is correct |
21 |
Correct |
82 ms |
11168 KB |
Output is correct |
22 |
Correct |
91 ms |
11208 KB |
Output is correct |
23 |
Correct |
104 ms |
10928 KB |
Output is correct |
24 |
Correct |
89 ms |
10796 KB |
Output is correct |
25 |
Correct |
103 ms |
10036 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
1640 KB |
Output is correct |
2 |
Correct |
12 ms |
1624 KB |
Output is correct |
3 |
Correct |
109 ms |
11084 KB |
Output is correct |
4 |
Correct |
146 ms |
11644 KB |
Output is correct |
5 |
Correct |
153 ms |
12912 KB |
Output is correct |
6 |
Correct |
152 ms |
13088 KB |
Output is correct |
7 |
Correct |
159 ms |
12912 KB |
Output is correct |
8 |
Incorrect |
175 ms |
12912 KB |
Output is incorrect: {s, t} is wrong. |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
1624 KB |
Output is correct |
2 |
Correct |
15 ms |
1624 KB |
Output is correct |
3 |
Partially correct |
133 ms |
11348 KB |
Output is partially correct |
4 |
Correct |
124 ms |
11412 KB |
Output is correct |
5 |
Partially correct |
130 ms |
11920 KB |
Output is partially correct |
6 |
Partially correct |
146 ms |
12752 KB |
Output is partially correct |
7 |
Partially correct |
119 ms |
11156 KB |
Output is partially correct |
8 |
Partially correct |
117 ms |
11352 KB |
Output is partially correct |
9 |
Partially correct |
126 ms |
11604 KB |
Output is partially correct |
10 |
Partially correct |
142 ms |
12892 KB |
Output is partially correct |
11 |
Partially correct |
144 ms |
12904 KB |
Output is partially correct |
12 |
Partially correct |
149 ms |
12840 KB |
Output is partially correct |
13 |
Incorrect |
151 ms |
10752 KB |
Output is incorrect: {s, t} is wrong. |
14 |
Halted |
0 ms |
0 KB |
- |