#include "Alicelib.h"
#include <cassert>
#include <cstdio>
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pi;
typedef vector<pi> vpi;
#define mp make_pair
#define f first
#define s second
#define pb push_back
#define sz(x) (int)(x).size()
static vpi eds;
static int deg[1505];
void Alice( int N, int M, int A[], int B[]){
eds.clear();
for(int i = 0; i < 1505; i++){
deg[i] = 0;
}
for(int i = 0; i < M; i++){
eds.pb(mp(A[i], B[i]));
}
for(int i = 0; i < N; i++){
for(int j = 0; j < 10; j++){
if((i>>j)&1){
eds.pb(mp(i, N+j));
}
}
}
vpi tree_eds = vpi{mp(0, 1), mp(0, 2), mp(2, 3), mp(0, 4), mp(4, 5), mp(5, 6), mp(6, 7), mp(7, 8), mp(8, 9)};
for(auto u: tree_eds){
eds.pb(mp(N+u.f, N+u.s));
}
for(auto u: eds){
deg[u.f]++;
deg[u.s]++;
}
for(int i = 0; i < N+10; i++){
if((deg[i]&1)^(i >= N)){
eds.pb(mp(i, N+10));
}
}
InitG(N+11, sz(eds));
// cout << "nodes: " << N+11 << "\n";
// cout << "Actual graph: " << "\n";
for(int i = 0; i < sz(eds); i++){
MakeG(i, eds[i].f, eds[i].s);
//cout << eds[i].f << " " << eds[i].s << "\n";
}
}
#include "Boblib.h"
#include <cassert>
#include <cstdio>
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vpi;
#define mp make_pair
#define f first
#define s second
#define pb push_back
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
static bool adj[1505][1505];
static int deg[1505];
static int original_ind[1505];
static bool pres[1505];
static vi small_adj[10];
static vi checkSmall(vpi small_eds){
// cout << "checkSmall(";
// for(auto u: small_eds){
// cout << u.f << " " << u.s << "\n";
// }
// cout << ")" << "\n";
if(sz(small_eds) != 9) return vi{};
for(auto u: small_eds){
assert(0 <= u.f && u.s <= 9);
}
int cen = -1;
for(int i = 0; i < 10; i++){
small_adj[i].clear();
}
for(auto u: small_eds){
small_adj[u.f].pb(u.s);
small_adj[u.s].pb(u.f);
}
for(int i = 0; i < 10; i++){
if(sz(small_adj[i]) == 3){
if(cen == -1){
cen = i;
}
else{
cen = -2;
}
}
}
if(cen < 0) return vi{};
//cout << "cen: " << cen << "\n";
vector<pair<int, vi>> branches;
bool works = 1;
for(auto node: small_adj[cen]){
vi branch;
int last_node = cen;
while(true){
if(node == cen){ //cycle
works = 0;
break;
}
branch.pb(node);
if(sz(small_adj[node]) == 1) break;
if(sz(small_adj[node]) != 2){
works = 0;
break;
}
if(small_adj[node][0] == last_node){
last_node = node;
node = small_adj[node][1];
}
else{
last_node = node;
node = small_adj[node][0];
}
}
branches.pb(mp(sz(branch), branch));
if(!works) break;
}
if(!works) return vi{};
sort(all(branches));
if(sz(branches) != 3 || branches[0].f != 1 || branches[1].f != 2 || branches[2].f != 6) return vi{};
vi res(10, 0);
res[0] = cen;
int cur = 0;
for(auto &u: branches){
for(auto &x: u.s){
res[++cur] = x;
}
}
// cout << "res: ";
// for(auto u: res){
// cout << u << " ";
// }
// cout << "\n";
return res;
}
void Bob( int V, int U, int C[], int D[] ){
for(int i = 0; i < 1505; i++){
for(int j = 0; j < 1505; j++){
adj[i][j] = 0;
}
}
for(int i = 0; i < 1505; i++){
deg[i] = 0;
original_ind[i] = 0;
}
int N = V-11;
//cout << "encrypted graph: " << "\n";
for(int i = 0; i < U; i++){
adj[C[i]][D[i]] = 1;
adj[D[i]][C[i]] = 1;
deg[C[i]]++; deg[D[i]]++;
//cout << C[i] << " " << D[i] << "\n";
}
vector<pair<int, vi>> bin_cands;
for(int spec_node = 0; spec_node < V; spec_node++){
vi dif_nodes;
for(int i = 0; i < V; i++){
if(spec_node == i) continue;
if(adj[i][spec_node]){
deg[i]--;
}
}
for(int i = 0; i < V; i++){
if(spec_node == i) continue;
bool is_dif = 0;
if(adj[i][spec_node]){
is_dif^=1;
}
if(deg[i]&1){
is_dif^=1;
}
if(is_dif){
dif_nodes.pb(i);
}
}
// if(spec_node == 7){
// cout << "dif_nodes: ";
// for(auto u: dif_nodes){
// cout << u << " ";
// }
// cout << "\n";
// }
for(int i = 0; i < V; i++){
if(spec_node == i) continue;
if(adj[i][spec_node]){
deg[i]++;
}
}
if(sz(dif_nodes) == 10){
bin_cands.pb(mp(spec_node, dif_nodes));
}
}
vpi ans;
for(auto x: bin_cands){
//cout << "spec node: " << x.f << "\n";
vi bins = x.s;
// cout << "bins: " << "\n";
// for(auto u: bins){
// cout << u << " ";
// }
// cout << "\n";
vpi small_eds;
for(int i = 0; i < sz(bins); i++){
for(int j = i+1; j < sz(bins); j++){
if(adj[bins[i]][bins[j]]){
small_eds.pb(mp(i, j));
}
}
}
vi res = checkSmall(small_eds); //bins[res[i]] is original node N+i
if(sz(res) == 0) continue;
for(int i = 0; i < V; i++){
original_ind[i] = 0;
}
for(int i = 0; i < 10; i++){
for(int j = 0; j < V; j++){
if(adj[bins[res[i]]][j]){
original_ind[j]+=(1<<i);
}
}
}
original_ind[x.f] = -1;
for(auto u: bins){
original_ind[u] = -1;
}
for(int i = 0; i < N; i++){
pres[i] = 0;
}
for(int i = 0; i < V; i++){
if(original_ind[i] == -1) continue;
if(0 <= original_ind[i] && original_ind[i] < N){
pres[original_ind[i]] = 1;
}
}
bool works = 1;
for(int i = 0; i < N; i++){
if(!pres[i]){
works = 0;
break;
}
}
if(!works) continue;
for(int i = 0; i < V; i++){
for(int j = i+1; j < V; j++){
if(original_ind[i] >= 0 && original_ind[j] >= 0){
if(adj[i][j]){
ans.pb(mp(original_ind[i], original_ind[j]));
}
}
}
}
break;
}
InitMap(V-11, sz(ans));
for(auto u: ans){
MakeMap(u.f, u.s);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
7224 KB |
Output is correct |
2 |
Correct |
8 ms |
7136 KB |
Output is correct |
3 |
Correct |
8 ms |
7156 KB |
Output is correct |
4 |
Correct |
8 ms |
7008 KB |
Output is correct |
5 |
Correct |
8 ms |
7224 KB |
Output is correct |
6 |
Correct |
8 ms |
7136 KB |
Output is correct |
7 |
Correct |
8 ms |
7136 KB |
Output is correct |
8 |
Correct |
8 ms |
7136 KB |
Output is correct |
9 |
Correct |
8 ms |
7008 KB |
Output is correct |
10 |
Correct |
8 ms |
7392 KB |
Output is correct |
11 |
Correct |
8 ms |
7264 KB |
Output is correct |
12 |
Correct |
8 ms |
7008 KB |
Output is correct |
13 |
Correct |
8 ms |
7008 KB |
Output is correct |
14 |
Correct |
8 ms |
7136 KB |
Output is correct |
15 |
Correct |
8 ms |
7136 KB |
Output is correct |
16 |
Correct |
7 ms |
7232 KB |
Output is correct |
17 |
Correct |
8 ms |
7224 KB |
Output is correct |
18 |
Correct |
8 ms |
7008 KB |
Output is correct |
19 |
Correct |
8 ms |
7224 KB |
Output is correct |
20 |
Correct |
8 ms |
7088 KB |
Output is correct |
21 |
Correct |
7 ms |
7008 KB |
Output is correct |
22 |
Correct |
8 ms |
7008 KB |
Output is correct |
23 |
Correct |
8 ms |
7224 KB |
Output is correct |
24 |
Correct |
8 ms |
7136 KB |
Output is correct |
25 |
Correct |
7 ms |
7008 KB |
Output is correct |
26 |
Correct |
7 ms |
7008 KB |
Output is correct |
27 |
Correct |
8 ms |
7220 KB |
Output is correct |
28 |
Correct |
8 ms |
7224 KB |
Output is correct |
29 |
Correct |
9 ms |
7136 KB |
Output is correct |
30 |
Correct |
7 ms |
7008 KB |
Output is correct |
31 |
Correct |
7 ms |
7008 KB |
Output is correct |
32 |
Correct |
8 ms |
7008 KB |
Output is correct |
33 |
Correct |
7 ms |
7232 KB |
Output is correct |
34 |
Correct |
8 ms |
7068 KB |
Output is correct |
35 |
Correct |
7 ms |
7068 KB |
Output is correct |
36 |
Correct |
8 ms |
7136 KB |
Output is correct |
37 |
Correct |
8 ms |
7256 KB |
Output is correct |
38 |
Correct |
8 ms |
7240 KB |
Output is correct |
39 |
Correct |
8 ms |
7136 KB |
Output is correct |
40 |
Correct |
8 ms |
7136 KB |
Output is correct |
41 |
Correct |
8 ms |
7232 KB |
Output is correct |
42 |
Correct |
9 ms |
7136 KB |
Output is correct |
43 |
Correct |
7 ms |
7008 KB |
Output is correct |
44 |
Correct |
8 ms |
7240 KB |
Output is correct |
45 |
Correct |
9 ms |
7008 KB |
Output is correct |
46 |
Correct |
9 ms |
7136 KB |
Output is correct |
47 |
Correct |
8 ms |
7264 KB |
Output is correct |
48 |
Correct |
8 ms |
7008 KB |
Output is correct |
49 |
Correct |
8 ms |
7136 KB |
Output is correct |
50 |
Correct |
8 ms |
7300 KB |
Output is correct |
51 |
Correct |
8 ms |
7232 KB |
Output is correct |
52 |
Correct |
7 ms |
7008 KB |
Output is correct |
53 |
Correct |
8 ms |
7008 KB |
Output is correct |
54 |
Correct |
8 ms |
7072 KB |
Output is correct |
55 |
Correct |
8 ms |
7224 KB |
Output is correct |
56 |
Correct |
7 ms |
7272 KB |
Output is correct |
57 |
Correct |
7 ms |
7232 KB |
Output is correct |
58 |
Correct |
8 ms |
7020 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
7224 KB |
Output is correct |
2 |
Correct |
8 ms |
7136 KB |
Output is correct |
3 |
Correct |
8 ms |
7156 KB |
Output is correct |
4 |
Correct |
8 ms |
7008 KB |
Output is correct |
5 |
Correct |
8 ms |
7224 KB |
Output is correct |
6 |
Correct |
8 ms |
7136 KB |
Output is correct |
7 |
Correct |
8 ms |
7136 KB |
Output is correct |
8 |
Correct |
8 ms |
7136 KB |
Output is correct |
9 |
Correct |
8 ms |
7008 KB |
Output is correct |
10 |
Correct |
8 ms |
7392 KB |
Output is correct |
11 |
Correct |
8 ms |
7264 KB |
Output is correct |
12 |
Correct |
8 ms |
7008 KB |
Output is correct |
13 |
Correct |
8 ms |
7008 KB |
Output is correct |
14 |
Correct |
8 ms |
7136 KB |
Output is correct |
15 |
Correct |
8 ms |
7136 KB |
Output is correct |
16 |
Correct |
7 ms |
7232 KB |
Output is correct |
17 |
Correct |
8 ms |
7224 KB |
Output is correct |
18 |
Correct |
8 ms |
7008 KB |
Output is correct |
19 |
Correct |
8 ms |
7224 KB |
Output is correct |
20 |
Correct |
8 ms |
7088 KB |
Output is correct |
21 |
Correct |
7 ms |
7008 KB |
Output is correct |
22 |
Correct |
8 ms |
7008 KB |
Output is correct |
23 |
Correct |
8 ms |
7224 KB |
Output is correct |
24 |
Correct |
8 ms |
7136 KB |
Output is correct |
25 |
Correct |
7 ms |
7008 KB |
Output is correct |
26 |
Correct |
7 ms |
7008 KB |
Output is correct |
27 |
Correct |
8 ms |
7220 KB |
Output is correct |
28 |
Correct |
8 ms |
7224 KB |
Output is correct |
29 |
Correct |
9 ms |
7136 KB |
Output is correct |
30 |
Correct |
7 ms |
7008 KB |
Output is correct |
31 |
Correct |
7 ms |
7008 KB |
Output is correct |
32 |
Correct |
8 ms |
7008 KB |
Output is correct |
33 |
Correct |
7 ms |
7232 KB |
Output is correct |
34 |
Correct |
8 ms |
7068 KB |
Output is correct |
35 |
Correct |
7 ms |
7068 KB |
Output is correct |
36 |
Correct |
8 ms |
7136 KB |
Output is correct |
37 |
Correct |
8 ms |
7256 KB |
Output is correct |
38 |
Correct |
8 ms |
7240 KB |
Output is correct |
39 |
Correct |
8 ms |
7136 KB |
Output is correct |
40 |
Correct |
8 ms |
7136 KB |
Output is correct |
41 |
Correct |
8 ms |
7232 KB |
Output is correct |
42 |
Correct |
9 ms |
7136 KB |
Output is correct |
43 |
Correct |
7 ms |
7008 KB |
Output is correct |
44 |
Correct |
8 ms |
7240 KB |
Output is correct |
45 |
Correct |
9 ms |
7008 KB |
Output is correct |
46 |
Correct |
9 ms |
7136 KB |
Output is correct |
47 |
Correct |
8 ms |
7264 KB |
Output is correct |
48 |
Correct |
8 ms |
7008 KB |
Output is correct |
49 |
Correct |
8 ms |
7136 KB |
Output is correct |
50 |
Correct |
8 ms |
7300 KB |
Output is correct |
51 |
Correct |
8 ms |
7232 KB |
Output is correct |
52 |
Correct |
7 ms |
7008 KB |
Output is correct |
53 |
Correct |
8 ms |
7008 KB |
Output is correct |
54 |
Correct |
8 ms |
7072 KB |
Output is correct |
55 |
Correct |
8 ms |
7224 KB |
Output is correct |
56 |
Correct |
7 ms |
7272 KB |
Output is correct |
57 |
Correct |
7 ms |
7232 KB |
Output is correct |
58 |
Correct |
8 ms |
7020 KB |
Output is correct |
59 |
Correct |
9 ms |
7136 KB |
Output is correct |
60 |
Correct |
9 ms |
7008 KB |
Output is correct |
61 |
Correct |
8 ms |
7212 KB |
Output is correct |
62 |
Correct |
8 ms |
7220 KB |
Output is correct |
63 |
Correct |
8 ms |
7008 KB |
Output is correct |
64 |
Correct |
9 ms |
7212 KB |
Output is correct |
65 |
Correct |
9 ms |
7136 KB |
Output is correct |
66 |
Correct |
8 ms |
7136 KB |
Output is correct |
67 |
Correct |
8 ms |
7336 KB |
Output is correct |
68 |
Correct |
8 ms |
7136 KB |
Output is correct |
69 |
Correct |
8 ms |
7008 KB |
Output is correct |
70 |
Correct |
8 ms |
7264 KB |
Output is correct |
71 |
Correct |
9 ms |
7208 KB |
Output is correct |
72 |
Correct |
9 ms |
7136 KB |
Output is correct |
73 |
Correct |
8 ms |
7136 KB |
Output is correct |
74 |
Correct |
8 ms |
7224 KB |
Output is correct |
75 |
Correct |
8 ms |
7008 KB |
Output is correct |
76 |
Correct |
8 ms |
7008 KB |
Output is correct |
77 |
Correct |
8 ms |
7136 KB |
Output is correct |
78 |
Correct |
9 ms |
7008 KB |
Output is correct |
79 |
Correct |
8 ms |
7008 KB |
Output is correct |
80 |
Correct |
10 ms |
7164 KB |
Output is correct |
81 |
Correct |
8 ms |
7008 KB |
Output is correct |
82 |
Correct |
8 ms |
7220 KB |
Output is correct |
83 |
Correct |
8 ms |
7224 KB |
Output is correct |
84 |
Correct |
9 ms |
7008 KB |
Output is correct |
85 |
Correct |
9 ms |
7244 KB |
Output is correct |
86 |
Correct |
8 ms |
7136 KB |
Output is correct |
87 |
Correct |
8 ms |
7008 KB |
Output is correct |
88 |
Correct |
8 ms |
7136 KB |
Output is correct |
89 |
Correct |
8 ms |
7008 KB |
Output is correct |
90 |
Correct |
8 ms |
7008 KB |
Output is correct |
91 |
Correct |
8 ms |
7228 KB |
Output is correct |
92 |
Correct |
8 ms |
7008 KB |
Output is correct |
93 |
Correct |
8 ms |
7008 KB |
Output is correct |
94 |
Correct |
8 ms |
7008 KB |
Output is correct |
95 |
Correct |
8 ms |
7136 KB |
Output is correct |
96 |
Correct |
9 ms |
7008 KB |
Output is correct |
97 |
Correct |
8 ms |
7200 KB |
Output is correct |
98 |
Correct |
8 ms |
7008 KB |
Output is correct |
99 |
Correct |
8 ms |
7008 KB |
Output is correct |
100 |
Correct |
8 ms |
7216 KB |
Output is correct |
101 |
Correct |
8 ms |
7180 KB |
Output is correct |
102 |
Correct |
8 ms |
7008 KB |
Output is correct |
103 |
Correct |
8 ms |
7136 KB |
Output is correct |
104 |
Correct |
8 ms |
7136 KB |
Output is correct |
105 |
Correct |
8 ms |
7136 KB |
Output is correct |
106 |
Correct |
8 ms |
7008 KB |
Output is correct |
107 |
Correct |
9 ms |
7136 KB |
Output is correct |
108 |
Correct |
8 ms |
7216 KB |
Output is correct |
109 |
Correct |
8 ms |
7008 KB |
Output is correct |
110 |
Correct |
8 ms |
7220 KB |
Output is correct |
111 |
Correct |
8 ms |
7136 KB |
Output is correct |
112 |
Correct |
9 ms |
7008 KB |
Output is correct |
113 |
Correct |
8 ms |
7216 KB |
Output is correct |
114 |
Correct |
8 ms |
7220 KB |
Output is correct |
115 |
Correct |
8 ms |
7008 KB |
Output is correct |
116 |
Correct |
8 ms |
7008 KB |
Output is correct |
117 |
Correct |
8 ms |
7008 KB |
Output is correct |
118 |
Correct |
8 ms |
7136 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
712 ms |
27580 KB |
Wrong Answer [11] |
2 |
Halted |
0 ms |
0 KB |
- |