#include "Alicelib.h"
#include <bits/stdc++.h>
using namespace std;
void Alice( int n, int m, int A[], int B[] ){
int cnt = 0;
vector<int> nums;
for(int i = 0;i < 1024;i++){
int bits = 0;
for(int j = 1;j < 1024;j *= 2){
if((i & j) != 0) bits++;
}
if(bits >= 2){
nums.push_back(i);
}
if(nums.size() == n) break;
}
typedef pair<int,int> ii;
vector<ii> edges;
for(int i = 0;i < m;i++){
edges.push_back(ii(A[i],B[i]));
}
int x = n+10;
int y = n+11;
int anchor[10];
for(int i = 0;i < 10;i++) anchor[i] = n+i;
edges.push_back(ii(x,y));
for(int i = 0;i < 10;i++){
edges.push_back(ii(y,anchor[i]));
}
for(int i = 1;i < 9;i++){
edges.push_back(ii(anchor[0],anchor[i]));
edges.push_back(ii(anchor[i],anchor[i+1]));
}
for(int i = 0;i < n;i++){
int k = nums[i];
for(int j = 0;j < 10;j++){
if((k & (1 << j)) != 0){
edges.push_back(ii(i,anchor[j]));
}
}
}
/*
for(ii x : edges){
cout << x.first << " " << x.second << "\n";
}
//*/
InitG(n+12,edges.size());
for(int i = 0;i < edges.size();i++){
MakeG(i,edges[i].first,edges[i].second);
}
//cout << "\n\n";
}
#include "Boblib.h"
#include <bits/stdc++.h>
using namespace std;
void Bob( int n, int m, int C[], int D[] ){
int on = n - 12;
vector<int> nums;
typedef pair<int,int> ii;
set<ii> edges;
for(int i = 0;i < 1024;i++){
int bits = 0;
for(int j = 1;j < 1024;j *= 2){
if((i & j) != 0) bits++;
}
if(bits >= 2){
nums.push_back(i);
}
if(nums.size() == on) break;
}
vector<int> adj[n];
for(int i = 0;i < m;i++){
adj[C[i]].push_back(D[i]);
adj[D[i]].push_back(C[i]);
//cout << C[i] << " " << D[i] << "\n";
edges.insert(ii(C[i],D[i]));
edges.insert(ii(D[i],C[i]));
}
int x, y;
for(int i = 0;i < n;i++){
if(adj[i].size() == 1){
x = i;
y = adj[i][0];
break;
}
}
//cout << x << "\n" << y << "\n";
vector<int> aa;
for(int i = 0;i < n;i++){
if(i == x || i == y){
continue;
}
if(edges.find(ii(i,y)) != edges.end()){
aa.push_back(i);
}
}
set<int> anchorSet;
for(int k : aa){
//cout << k << " ";
anchorSet.insert(k);
}
int anchor[10];
fill(anchor,anchor+10,-1);
for(int i = 0;i < 10;i++){
int cnt = 0;
for(int j = 0;j < 10;j++){
if(edges.find(ii(aa[i],aa[j])) != edges.end()){
cnt++;
}
}
if(cnt == 8){
anchor[0] = aa[i];
}
else if(cnt == 1){
anchor[9] = aa[i];
}
}
int cur = anchor[9];
for(int i = 9;i >= 2;i--){
for(int v : adj[cur]){
if(v != anchor[0] && anchorSet.find(v) != anchorSet.end()){
if(i == 9 || v != anchor[i+1]){
cur = v;
anchor[i-1] = cur;
break;
}
}
}
}
unordered_set<int> extras;
unordered_map<int,int> anchorMap;
//cout << "\n";
for(int i =0 ;i < 10;i++){
//cout << anchor[i] << " ";
extras.insert(anchor[i]);
anchorMap[anchor[i]] = i;
}
extras.insert(x);
extras.insert(y);
//cout << "\n";
unordered_map<int,int> normalMap;
for(int u = 0;u < n;u++){
int value = 0;
if(extras.find(u) != extras.end()) continue;
for(int v : adj[u]){
if(extras.find(v) == extras.end()) continue;
int bit = anchorMap[v];
value |= (1 << bit);
}
int pos = lower_bound(nums.begin(),nums.end(),value) - nums.begin();
normalMap[u] = pos;
//cout << u << " " << pos << "\n";
}
vector<ii> finalEdges;
for(int i = 0;i < m;i++){
int u = C[i];
int v = D[i];
if(extras.find(u) != extras.end() || extras.find(v) != extras.end()) continue;
finalEdges.push_back(ii(normalMap[u],normalMap[v]));
}
//cout << "\n";
//for(ii k : finalEdges) cout << k.first << " " << k.second << "\n";
InitMap(on, finalEdges.size());
for(ii k : finalEdges) MakeMap(k.first,k.second);
}
Compilation message
Alice.cpp: In function 'void Alice(int, int, int*, int*)':
Alice.cpp:16:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(nums.size() == n) break;
~~~~~~~~~~~~^~~~
Alice.cpp:54:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0;i < edges.size();i++){
~~^~~~~~~~~~~~~~
Alice.cpp:6:6: warning: unused variable 'cnt' [-Wunused-variable]
int cnt = 0;
^~~
Bob.cpp: In function 'void Bob(int, int, int*, int*)':
Bob.cpp:18:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(nums.size() == on) break;
~~~~~~~~~~~~^~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
6640 KB |
Output is correct |
2 |
Correct |
9 ms |
6640 KB |
Output is correct |
3 |
Correct |
9 ms |
6640 KB |
Output is correct |
4 |
Correct |
9 ms |
6640 KB |
Output is correct |
5 |
Correct |
9 ms |
6896 KB |
Output is correct |
6 |
Correct |
9 ms |
6640 KB |
Output is correct |
7 |
Correct |
9 ms |
6640 KB |
Output is correct |
8 |
Correct |
9 ms |
6640 KB |
Output is correct |
9 |
Correct |
9 ms |
6896 KB |
Output is correct |
10 |
Correct |
9 ms |
6896 KB |
Output is correct |
11 |
Correct |
9 ms |
6560 KB |
Output is correct |
12 |
Correct |
9 ms |
6640 KB |
Output is correct |
13 |
Correct |
9 ms |
6896 KB |
Output is correct |
14 |
Correct |
9 ms |
6640 KB |
Output is correct |
15 |
Correct |
9 ms |
6640 KB |
Output is correct |
16 |
Correct |
9 ms |
6896 KB |
Output is correct |
17 |
Correct |
9 ms |
6896 KB |
Output is correct |
18 |
Correct |
9 ms |
6640 KB |
Output is correct |
19 |
Correct |
9 ms |
6896 KB |
Output is correct |
20 |
Correct |
9 ms |
6896 KB |
Output is correct |
21 |
Correct |
9 ms |
6640 KB |
Output is correct |
22 |
Correct |
9 ms |
6896 KB |
Output is correct |
23 |
Correct |
9 ms |
6640 KB |
Output is correct |
24 |
Correct |
9 ms |
6640 KB |
Output is correct |
25 |
Correct |
9 ms |
6896 KB |
Output is correct |
26 |
Correct |
9 ms |
6648 KB |
Output is correct |
27 |
Correct |
9 ms |
6640 KB |
Output is correct |
28 |
Correct |
9 ms |
6896 KB |
Output is correct |
29 |
Correct |
9 ms |
6640 KB |
Output is correct |
30 |
Correct |
9 ms |
6896 KB |
Output is correct |
31 |
Correct |
9 ms |
6896 KB |
Output is correct |
32 |
Correct |
9 ms |
6648 KB |
Output is correct |
33 |
Correct |
9 ms |
6896 KB |
Output is correct |
34 |
Correct |
9 ms |
6896 KB |
Output is correct |
35 |
Correct |
9 ms |
6896 KB |
Output is correct |
36 |
Correct |
9 ms |
6896 KB |
Output is correct |
37 |
Correct |
9 ms |
6896 KB |
Output is correct |
38 |
Correct |
9 ms |
6896 KB |
Output is correct |
39 |
Correct |
9 ms |
6896 KB |
Output is correct |
40 |
Correct |
9 ms |
6896 KB |
Output is correct |
41 |
Correct |
9 ms |
6640 KB |
Output is correct |
42 |
Correct |
9 ms |
6896 KB |
Output is correct |
43 |
Correct |
9 ms |
6640 KB |
Output is correct |
44 |
Correct |
9 ms |
6896 KB |
Output is correct |
45 |
Correct |
9 ms |
6896 KB |
Output is correct |
46 |
Correct |
9 ms |
6640 KB |
Output is correct |
47 |
Correct |
9 ms |
6640 KB |
Output is correct |
48 |
Correct |
8 ms |
6640 KB |
Output is correct |
49 |
Correct |
9 ms |
6640 KB |
Output is correct |
50 |
Correct |
9 ms |
6640 KB |
Output is correct |
51 |
Correct |
9 ms |
6896 KB |
Output is correct |
52 |
Correct |
9 ms |
6896 KB |
Output is correct |
53 |
Correct |
9 ms |
6640 KB |
Output is correct |
54 |
Correct |
9 ms |
6896 KB |
Output is correct |
55 |
Correct |
9 ms |
6640 KB |
Output is correct |
56 |
Correct |
9 ms |
6896 KB |
Output is correct |
57 |
Correct |
9 ms |
6896 KB |
Output is correct |
58 |
Correct |
9 ms |
6896 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
6640 KB |
Output is correct |
2 |
Correct |
9 ms |
6640 KB |
Output is correct |
3 |
Correct |
9 ms |
6640 KB |
Output is correct |
4 |
Correct |
9 ms |
6640 KB |
Output is correct |
5 |
Correct |
9 ms |
6896 KB |
Output is correct |
6 |
Correct |
9 ms |
6640 KB |
Output is correct |
7 |
Correct |
9 ms |
6640 KB |
Output is correct |
8 |
Correct |
9 ms |
6640 KB |
Output is correct |
9 |
Correct |
9 ms |
6896 KB |
Output is correct |
10 |
Correct |
9 ms |
6896 KB |
Output is correct |
11 |
Correct |
9 ms |
6560 KB |
Output is correct |
12 |
Correct |
9 ms |
6640 KB |
Output is correct |
13 |
Correct |
9 ms |
6896 KB |
Output is correct |
14 |
Correct |
9 ms |
6640 KB |
Output is correct |
15 |
Correct |
9 ms |
6640 KB |
Output is correct |
16 |
Correct |
9 ms |
6896 KB |
Output is correct |
17 |
Correct |
9 ms |
6896 KB |
Output is correct |
18 |
Correct |
9 ms |
6640 KB |
Output is correct |
19 |
Correct |
9 ms |
6896 KB |
Output is correct |
20 |
Correct |
9 ms |
6896 KB |
Output is correct |
21 |
Correct |
9 ms |
6640 KB |
Output is correct |
22 |
Correct |
9 ms |
6896 KB |
Output is correct |
23 |
Correct |
9 ms |
6640 KB |
Output is correct |
24 |
Correct |
9 ms |
6640 KB |
Output is correct |
25 |
Correct |
9 ms |
6896 KB |
Output is correct |
26 |
Correct |
9 ms |
6648 KB |
Output is correct |
27 |
Correct |
9 ms |
6640 KB |
Output is correct |
28 |
Correct |
9 ms |
6896 KB |
Output is correct |
29 |
Correct |
9 ms |
6640 KB |
Output is correct |
30 |
Correct |
9 ms |
6896 KB |
Output is correct |
31 |
Correct |
9 ms |
6896 KB |
Output is correct |
32 |
Correct |
9 ms |
6648 KB |
Output is correct |
33 |
Correct |
9 ms |
6896 KB |
Output is correct |
34 |
Correct |
9 ms |
6896 KB |
Output is correct |
35 |
Correct |
9 ms |
6896 KB |
Output is correct |
36 |
Correct |
9 ms |
6896 KB |
Output is correct |
37 |
Correct |
9 ms |
6896 KB |
Output is correct |
38 |
Correct |
9 ms |
6896 KB |
Output is correct |
39 |
Correct |
9 ms |
6896 KB |
Output is correct |
40 |
Correct |
9 ms |
6896 KB |
Output is correct |
41 |
Correct |
9 ms |
6640 KB |
Output is correct |
42 |
Correct |
9 ms |
6896 KB |
Output is correct |
43 |
Correct |
9 ms |
6640 KB |
Output is correct |
44 |
Correct |
9 ms |
6896 KB |
Output is correct |
45 |
Correct |
9 ms |
6896 KB |
Output is correct |
46 |
Correct |
9 ms |
6640 KB |
Output is correct |
47 |
Correct |
9 ms |
6640 KB |
Output is correct |
48 |
Correct |
8 ms |
6640 KB |
Output is correct |
49 |
Correct |
9 ms |
6640 KB |
Output is correct |
50 |
Correct |
9 ms |
6640 KB |
Output is correct |
51 |
Correct |
9 ms |
6896 KB |
Output is correct |
52 |
Correct |
9 ms |
6896 KB |
Output is correct |
53 |
Correct |
9 ms |
6640 KB |
Output is correct |
54 |
Correct |
9 ms |
6896 KB |
Output is correct |
55 |
Correct |
9 ms |
6640 KB |
Output is correct |
56 |
Correct |
9 ms |
6896 KB |
Output is correct |
57 |
Correct |
9 ms |
6896 KB |
Output is correct |
58 |
Correct |
9 ms |
6896 KB |
Output is correct |
59 |
Correct |
10 ms |
6648 KB |
Output is correct |
60 |
Correct |
10 ms |
6712 KB |
Output is correct |
61 |
Correct |
11 ms |
6896 KB |
Output is correct |
62 |
Correct |
9 ms |
6896 KB |
Output is correct |
63 |
Correct |
9 ms |
6640 KB |
Output is correct |
64 |
Correct |
10 ms |
6896 KB |
Output is correct |
65 |
Correct |
10 ms |
6640 KB |
Output is correct |
66 |
Correct |
10 ms |
6640 KB |
Output is correct |
67 |
Correct |
10 ms |
6640 KB |
Output is correct |
68 |
Correct |
9 ms |
6640 KB |
Output is correct |
69 |
Correct |
9 ms |
6640 KB |
Output is correct |
70 |
Correct |
9 ms |
6640 KB |
Output is correct |
71 |
Correct |
10 ms |
6640 KB |
Output is correct |
72 |
Correct |
10 ms |
6896 KB |
Output is correct |
73 |
Correct |
9 ms |
6640 KB |
Output is correct |
74 |
Correct |
9 ms |
6640 KB |
Output is correct |
75 |
Correct |
9 ms |
6896 KB |
Output is correct |
76 |
Correct |
9 ms |
6648 KB |
Output is correct |
77 |
Correct |
10 ms |
6640 KB |
Output is correct |
78 |
Correct |
10 ms |
6640 KB |
Output is correct |
79 |
Correct |
10 ms |
6896 KB |
Output is correct |
80 |
Correct |
10 ms |
6640 KB |
Output is correct |
81 |
Correct |
9 ms |
6640 KB |
Output is correct |
82 |
Correct |
9 ms |
6896 KB |
Output is correct |
83 |
Correct |
9 ms |
6896 KB |
Output is correct |
84 |
Correct |
9 ms |
6640 KB |
Output is correct |
85 |
Correct |
10 ms |
6648 KB |
Output is correct |
86 |
Correct |
9 ms |
6896 KB |
Output is correct |
87 |
Correct |
9 ms |
6896 KB |
Output is correct |
88 |
Correct |
8 ms |
6640 KB |
Output is correct |
89 |
Correct |
9 ms |
6736 KB |
Output is correct |
90 |
Correct |
9 ms |
6640 KB |
Output is correct |
91 |
Correct |
9 ms |
6640 KB |
Output is correct |
92 |
Correct |
9 ms |
6640 KB |
Output is correct |
93 |
Correct |
9 ms |
6640 KB |
Output is correct |
94 |
Correct |
10 ms |
6896 KB |
Output is correct |
95 |
Correct |
10 ms |
6640 KB |
Output is correct |
96 |
Correct |
10 ms |
6640 KB |
Output is correct |
97 |
Correct |
10 ms |
6640 KB |
Output is correct |
98 |
Correct |
10 ms |
6640 KB |
Output is correct |
99 |
Correct |
10 ms |
6640 KB |
Output is correct |
100 |
Correct |
9 ms |
6896 KB |
Output is correct |
101 |
Correct |
9 ms |
6640 KB |
Output is correct |
102 |
Correct |
9 ms |
6640 KB |
Output is correct |
103 |
Correct |
9 ms |
6640 KB |
Output is correct |
104 |
Correct |
9 ms |
6640 KB |
Output is correct |
105 |
Correct |
9 ms |
6640 KB |
Output is correct |
106 |
Correct |
10 ms |
6896 KB |
Output is correct |
107 |
Correct |
9 ms |
6768 KB |
Output is correct |
108 |
Correct |
9 ms |
6640 KB |
Output is correct |
109 |
Correct |
10 ms |
6640 KB |
Output is correct |
110 |
Correct |
9 ms |
6896 KB |
Output is correct |
111 |
Correct |
9 ms |
6896 KB |
Output is correct |
112 |
Correct |
10 ms |
6896 KB |
Output is correct |
113 |
Correct |
9 ms |
6896 KB |
Output is correct |
114 |
Correct |
9 ms |
6896 KB |
Output is correct |
115 |
Correct |
10 ms |
6640 KB |
Output is correct |
116 |
Correct |
9 ms |
6896 KB |
Output is correct |
117 |
Correct |
10 ms |
6640 KB |
Output is correct |
118 |
Correct |
10 ms |
6640 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2530 ms |
76592 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |