#include "Alicelib.h"
#include <cassert>
#include <cstdio>
#include <iostream>
#include <array>
#include <vector>
#define ll long long
using namespace std;
void Alice( int N, int M, int A[], int B[] ){
vector <array<ll, 2>> V;
ll k = N, tot = 0, cnt = N;
while (k) {
k /= 2;
++tot;
}
for (int i=0; i<M; ++i) {
V.push_back({A[i], B[i]});
}
k = 1;
for (int i=0; i<tot; ++i) {
for (int j=0; j<N; ++j) {
if ((j+1) & k) V.push_back({cnt, j});
}
if (i != tot-1) V.push_back({cnt, cnt+1});
++cnt, k *= 2;
}
for (int i=0; i<cnt; ++i) {
if (N == i) continue;
V.push_back({i, cnt});
}
if (N < 10) {
for (int i=1; i<5; ++i) {
++cnt;
V.push_back({cnt-i, cnt});
}
}
++cnt;
for (int j=N; j<N+tot; ++j) {
V.push_back({j, cnt});
}
++cnt;
InitG(cnt, V.size());
int i = 0;
for (auto [a, b] : V) {
//cout << a << " " << b << endl;
MakeG(i++, a, b);
}
}
#include "Boblib.h"
#include <cassert>
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <array>
#define ll long long
using namespace std;
ll in[2000], F[2000];
bool B[2000], G[2000];
vector <ll> adj[2000], Q;
vector <array<ll, 2> > V, X;
ll n, x, z, rt = 0, st = 0;
void dfs(ll u, ll p, ll k) {
for (auto v : adj[u]) {
if (!G[v] && v != rt && v != z) {
F[v] += k;
}
}
for (auto v : adj[u]) {
if (G[v] && v != p) dfs(v, u, k*2);
}
}
void Bob( int Z, int U, int C[], int D[] ){
n = Z;
Q.clear();
V.clear();
X.clear();
for (int i=0; i<n; ++i) in[i] = B[i] = F[i] = G[i] = 0, adj[i].clear();
for (int i=0; i<U; ++i) {
++in[C[i]], ++in[D[i]];
adj[C[i]].push_back(D[i]);
adj[D[i]].push_back(C[i]);
}
x = 0;
for (int i=0; i<n; ++i) {
if (in[i] == 1) --x;
if (in[i] == n-3) {
rt = i;
}
}
B[rt] = 1;
for (auto v : adj[rt]) {
B[v] = 1;
}
z = rt;
for (int i=0; i<n; ++i) {
if (!B[i]) {
Q.push_back(i);
}
}
//cout << adj[Q[0]].size() << " " << adj[Q[1]].size() << endl;
if (adj[Q[0]].size() >= adj[Q[1]].size()) rt = Q[1], st = Q[0];
else rt = Q[0], st = Q[1];
x += Z-2-adj[rt].size();
for (auto v : adj[rt]) {
in[v] -= 2;
G[v] = 1;
}
dfs(st, -1, 1);
/*for (int i=0; i<n; ++i) {
cout << F[i] << " ";
}
cout << endl;*/
for (int i=0; i<U; ++i) {
if (F[C[i]] && F[D[i]]) {
//cout << F[C[i]]-1 << " " << F[D[i]]-1 << endl;
V.push_back({F[C[i]]-1, F[D[i]]-1});
}
}
InitMap(x, V.size());
for (auto [a, b] : V) {
MakeMap(a, b);
}
}
Compilation message
Bob.cpp: In function 'void Bob(int, int, int*, int*)':
Bob.cpp:33:46: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
33 | for (int i=0; i<n; ++i) in[i] = B[i] = F[i] = G[i] = 0, adj[i].clear();
| ~~~~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
15620 KB |
Wrong Answer [12] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
15620 KB |
Wrong Answer [12] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
361 ms |
50368 KB |
Output is correct : V - N = 12 |
2 |
Correct |
296 ms |
50320 KB |
Output is correct : V - N = 12 |
3 |
Correct |
152 ms |
28288 KB |
Output is correct : V - N = 12 |
4 |
Correct |
8 ms |
16016 KB |
Output is correct : V - N = 12 |
5 |
Correct |
70 ms |
21420 KB |
Output is correct : V - N = 12 |
6 |
Correct |
257 ms |
48040 KB |
Output is correct : V - N = 12 |
7 |
Correct |
368 ms |
50540 KB |
Output is correct : V - N = 12 |
8 |
Correct |
311 ms |
51112 KB |
Output is correct : V - N = 12 |
9 |
Correct |
161 ms |
29056 KB |
Output is correct : V - N = 12 |
10 |
Correct |
16 ms |
17388 KB |
Output is correct : V - N = 12 |
11 |
Correct |
33 ms |
18648 KB |
Output is correct : V - N = 12 |
12 |
Correct |
190 ms |
36552 KB |
Output is correct : V - N = 12 |
13 |
Correct |
336 ms |
50564 KB |
Output is correct : V - N = 12 |
14 |
Correct |
435 ms |
51080 KB |
Output is correct : V - N = 12 |
15 |
Correct |
223 ms |
43916 KB |
Output is correct : V - N = 12 |
16 |
Correct |
47 ms |
19672 KB |
Output is correct : V - N = 12 |
17 |
Correct |
11 ms |
16772 KB |
Output is correct : V - N = 12 |
18 |
Correct |
139 ms |
28560 KB |
Output is correct : V - N = 12 |
19 |
Correct |
360 ms |
49316 KB |
Output is correct : V - N = 12 |
20 |
Correct |
453 ms |
51400 KB |
Output is correct : V - N = 12 |
21 |
Incorrect |
97 ms |
25472 KB |
Wrong Answer [14] |
22 |
Halted |
0 ms |
0 KB |
- |