#include "Alicelib.h"
#include <bits/stdc++.h>
using namespace std;
/// 11:18
static vector<pair<int,int>> edges;
static void add_edge(int x, int y)
{
edges.push_back({x, y});
}
void Alice( int N, int M, int A[], int B[] )
{
int S1, S2;
S1 = N+10;
S2 = N+11;
add_edge(S1, S2);
int i, j;
for(i=0; i<M; ++i)
add_edge(A[i], B[i]);
for(i=0; i<N; ++i)
for(j=0; j<10; ++j)
if(i & (1<<j))
add_edge(i, N+j);
for(i=0; i<10; ++i)
{
add_edge(N+i, S1);
add_edge(N+i, S2);
if(i) add_edge(N+i, N+i-1);
}
add_edge(N+1, N+3);
InitG(N+12, edges.size());
int nr = 0;
for(auto it : edges) MakeG(nr++, it.first, it.second);
}
#include "Boblib.h"
#include <bits/stdc++.h>
using namespace std;
static int n, V, P[1005];
static vector<pair<int,int>> edges;
static vector<vector<int>> v;
static bitset<1005> bad;
static void add_edge(int x, int y)
{
edges.push_back({x, y});
}
bool sortt(vector<int> &p)
{
vector<vector<int>> gr(V);
for(auto it : p)
for(auto it2 : p)
if(find(v[it].begin(), v[it].end(), it2) != v[it].end())
gr[it].push_back(it2);
vector<int> sp;
for(auto it : p)
if(gr[it].size() == 3) sp.push_back(it);
if(sp.size() != 2) return 0;
for(auto it : p)
if(gr[it].size() != 2 && gr[it].size() != 3 && gr[it].size() != 1) return 0;
int node = sp[0];
gr[node].erase(find(gr[node].begin(), gr[node].end(), sp[1]));
node = sp[1];
gr[node].erase(find(gr[node].begin(), gr[node].end(), sp[0]));
vector<int> vec[2];
for(int step = 0; step < 2; ++step)
{
int prv = sp[0];
node = gr[sp[0]][step];
while(gr[node].size() == 2)
{
vec[step].push_back(node);
int prr = node;
node = gr[node][0] ^ gr[node][1] ^ prv;
prv = prr;
}
vec[step].push_back(node);
}
if(vec[0].size() > vec[1].size()) swap(vec[0], vec[1]);
reverse(vec[0].begin(), vec[0].end());
p.clear();
p.insert(p.end(), vec[0].begin(), vec[0].end());
p.insert(p.end(), sp[0]);
p.insert(p.end(), vec[1].begin(), vec[1].end());
return 1;
}
bool Try(int A, int B)
{
if(v[A].size() != 11 || v[B].size() != 11) return 0;
vector<int> p = v[A];
p.erase(find(p.begin(), p.end(), B));
for(auto it : p)
if(find(v[B].begin(), v[B].end(), it) == v[B].end()) return 0;
int sum = 0, i, j;
for(i=0; i<n; ++i)
for(j=0; j<10; ++j)
if(i & (1<<j))
++sum;
sum += 20 + 20;
int sum2 = 0;
for(auto it : p)
sum2 += v[it].size();
if(sum != sum2) return 0;
bad.reset();
edges.clear();
bad[A] = bad[B] = 1;
for(auto it : p) bad[it] = 1;
for(i=0; i<V; ++i)
for(auto it : v[i])
if(!bad[i] && !bad[it] && i < it)
add_edge(i, it);
if(!sortt(p)) return 0;
vector<int> where(V);
for(i=0; i<10; ++i)
where[p[i]] = i;
vector<int> all;
for(i=0; i<V; ++i)
if(!bad[i])
{
P[i] = 0;
for(auto it : v[i])
if(bad[it])
P[i] ^= (1<<where[it]);
all.push_back(P[i]);
}
sort(all.begin(), all.end());
assert(all.size() == n);
for(i=0; i<n; ++i)
if(all[i] != i) return 0;
InitMap(n, edges.size());
for(auto it : edges)
MakeMap(P[it.first], P[it.second]);
return 1;
}
void Bob( int _V, int U, int C[], int D[] )
{
V = _V;
n = V - 12;
int i;
v.resize(V);
for(i=0; i<U; ++i)
{
v[C[i]].push_back(D[i]);
v[D[i]].push_back(C[i]);
}
for(i=0; i<V; ++i)
for(auto it : v[i])
if(Try(i, it)) return;
}
Compilation message
In file included from /usr/include/c++/7/cassert:44:0,
from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:33,
from Bob.cpp:2:
Bob.cpp: In function 'bool Try(int, int)':
Bob.cpp:125:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
assert(all.size() == n);
~~~~~~~~~~~^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
14 ms |
6656 KB |
Output is correct |
2 |
Correct |
13 ms |
6656 KB |
Output is correct |
3 |
Correct |
14 ms |
6656 KB |
Output is correct |
4 |
Correct |
13 ms |
6656 KB |
Output is correct |
5 |
Correct |
13 ms |
6912 KB |
Output is correct |
6 |
Correct |
13 ms |
6912 KB |
Output is correct |
7 |
Correct |
13 ms |
6656 KB |
Output is correct |
8 |
Correct |
13 ms |
6656 KB |
Output is correct |
9 |
Correct |
13 ms |
6656 KB |
Output is correct |
10 |
Correct |
12 ms |
6912 KB |
Output is correct |
11 |
Correct |
13 ms |
6656 KB |
Output is correct |
12 |
Correct |
13 ms |
6912 KB |
Output is correct |
13 |
Correct |
13 ms |
6912 KB |
Output is correct |
14 |
Correct |
14 ms |
6656 KB |
Output is correct |
15 |
Correct |
13 ms |
6656 KB |
Output is correct |
16 |
Correct |
13 ms |
6912 KB |
Output is correct |
17 |
Correct |
13 ms |
6912 KB |
Output is correct |
18 |
Correct |
13 ms |
6656 KB |
Output is correct |
19 |
Correct |
13 ms |
6912 KB |
Output is correct |
20 |
Correct |
13 ms |
6656 KB |
Output is correct |
21 |
Correct |
13 ms |
6912 KB |
Output is correct |
22 |
Correct |
13 ms |
6656 KB |
Output is correct |
23 |
Correct |
14 ms |
6656 KB |
Output is correct |
24 |
Correct |
13 ms |
6912 KB |
Output is correct |
25 |
Correct |
13 ms |
6656 KB |
Output is correct |
26 |
Correct |
14 ms |
6912 KB |
Output is correct |
27 |
Correct |
13 ms |
6656 KB |
Output is correct |
28 |
Correct |
13 ms |
6656 KB |
Output is correct |
29 |
Correct |
13 ms |
6656 KB |
Output is correct |
30 |
Correct |
14 ms |
6656 KB |
Output is correct |
31 |
Correct |
13 ms |
6656 KB |
Output is correct |
32 |
Correct |
13 ms |
6912 KB |
Output is correct |
33 |
Correct |
13 ms |
6656 KB |
Output is correct |
34 |
Correct |
13 ms |
6656 KB |
Output is correct |
35 |
Correct |
13 ms |
6912 KB |
Output is correct |
36 |
Correct |
13 ms |
6912 KB |
Output is correct |
37 |
Correct |
13 ms |
6656 KB |
Output is correct |
38 |
Correct |
16 ms |
6656 KB |
Output is correct |
39 |
Correct |
15 ms |
6656 KB |
Output is correct |
40 |
Correct |
13 ms |
6912 KB |
Output is correct |
41 |
Correct |
13 ms |
6656 KB |
Output is correct |
42 |
Correct |
15 ms |
6656 KB |
Output is correct |
43 |
Correct |
13 ms |
6656 KB |
Output is correct |
44 |
Correct |
13 ms |
6656 KB |
Output is correct |
45 |
Correct |
14 ms |
6912 KB |
Output is correct |
46 |
Correct |
13 ms |
6656 KB |
Output is correct |
47 |
Correct |
13 ms |
6656 KB |
Output is correct |
48 |
Correct |
13 ms |
6912 KB |
Output is correct |
49 |
Correct |
13 ms |
6760 KB |
Output is correct |
50 |
Correct |
13 ms |
6656 KB |
Output is correct |
51 |
Correct |
13 ms |
6656 KB |
Output is correct |
52 |
Correct |
13 ms |
6656 KB |
Output is correct |
53 |
Correct |
13 ms |
6912 KB |
Output is correct |
54 |
Correct |
13 ms |
6656 KB |
Output is correct |
55 |
Correct |
14 ms |
6912 KB |
Output is correct |
56 |
Correct |
14 ms |
6656 KB |
Output is correct |
57 |
Correct |
13 ms |
6912 KB |
Output is correct |
58 |
Correct |
13 ms |
6912 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
14 ms |
6656 KB |
Output is correct |
2 |
Correct |
13 ms |
6656 KB |
Output is correct |
3 |
Correct |
14 ms |
6656 KB |
Output is correct |
4 |
Correct |
13 ms |
6656 KB |
Output is correct |
5 |
Correct |
13 ms |
6912 KB |
Output is correct |
6 |
Correct |
13 ms |
6912 KB |
Output is correct |
7 |
Correct |
13 ms |
6656 KB |
Output is correct |
8 |
Correct |
13 ms |
6656 KB |
Output is correct |
9 |
Correct |
13 ms |
6656 KB |
Output is correct |
10 |
Correct |
12 ms |
6912 KB |
Output is correct |
11 |
Correct |
13 ms |
6656 KB |
Output is correct |
12 |
Correct |
13 ms |
6912 KB |
Output is correct |
13 |
Correct |
13 ms |
6912 KB |
Output is correct |
14 |
Correct |
14 ms |
6656 KB |
Output is correct |
15 |
Correct |
13 ms |
6656 KB |
Output is correct |
16 |
Correct |
13 ms |
6912 KB |
Output is correct |
17 |
Correct |
13 ms |
6912 KB |
Output is correct |
18 |
Correct |
13 ms |
6656 KB |
Output is correct |
19 |
Correct |
13 ms |
6912 KB |
Output is correct |
20 |
Correct |
13 ms |
6656 KB |
Output is correct |
21 |
Correct |
13 ms |
6912 KB |
Output is correct |
22 |
Correct |
13 ms |
6656 KB |
Output is correct |
23 |
Correct |
14 ms |
6656 KB |
Output is correct |
24 |
Correct |
13 ms |
6912 KB |
Output is correct |
25 |
Correct |
13 ms |
6656 KB |
Output is correct |
26 |
Correct |
14 ms |
6912 KB |
Output is correct |
27 |
Correct |
13 ms |
6656 KB |
Output is correct |
28 |
Correct |
13 ms |
6656 KB |
Output is correct |
29 |
Correct |
13 ms |
6656 KB |
Output is correct |
30 |
Correct |
14 ms |
6656 KB |
Output is correct |
31 |
Correct |
13 ms |
6656 KB |
Output is correct |
32 |
Correct |
13 ms |
6912 KB |
Output is correct |
33 |
Correct |
13 ms |
6656 KB |
Output is correct |
34 |
Correct |
13 ms |
6656 KB |
Output is correct |
35 |
Correct |
13 ms |
6912 KB |
Output is correct |
36 |
Correct |
13 ms |
6912 KB |
Output is correct |
37 |
Correct |
13 ms |
6656 KB |
Output is correct |
38 |
Correct |
16 ms |
6656 KB |
Output is correct |
39 |
Correct |
15 ms |
6656 KB |
Output is correct |
40 |
Correct |
13 ms |
6912 KB |
Output is correct |
41 |
Correct |
13 ms |
6656 KB |
Output is correct |
42 |
Correct |
15 ms |
6656 KB |
Output is correct |
43 |
Correct |
13 ms |
6656 KB |
Output is correct |
44 |
Correct |
13 ms |
6656 KB |
Output is correct |
45 |
Correct |
14 ms |
6912 KB |
Output is correct |
46 |
Correct |
13 ms |
6656 KB |
Output is correct |
47 |
Correct |
13 ms |
6656 KB |
Output is correct |
48 |
Correct |
13 ms |
6912 KB |
Output is correct |
49 |
Correct |
13 ms |
6760 KB |
Output is correct |
50 |
Correct |
13 ms |
6656 KB |
Output is correct |
51 |
Correct |
13 ms |
6656 KB |
Output is correct |
52 |
Correct |
13 ms |
6656 KB |
Output is correct |
53 |
Correct |
13 ms |
6912 KB |
Output is correct |
54 |
Correct |
13 ms |
6656 KB |
Output is correct |
55 |
Correct |
14 ms |
6912 KB |
Output is correct |
56 |
Correct |
14 ms |
6656 KB |
Output is correct |
57 |
Correct |
13 ms |
6912 KB |
Output is correct |
58 |
Correct |
13 ms |
6912 KB |
Output is correct |
59 |
Correct |
13 ms |
7168 KB |
Output is correct |
60 |
Correct |
13 ms |
6656 KB |
Output is correct |
61 |
Correct |
13 ms |
6656 KB |
Output is correct |
62 |
Correct |
13 ms |
6912 KB |
Output is correct |
63 |
Correct |
13 ms |
6656 KB |
Output is correct |
64 |
Correct |
14 ms |
6656 KB |
Output is correct |
65 |
Correct |
14 ms |
6656 KB |
Output is correct |
66 |
Correct |
14 ms |
6912 KB |
Output is correct |
67 |
Correct |
15 ms |
6912 KB |
Output is correct |
68 |
Correct |
14 ms |
6656 KB |
Output is correct |
69 |
Correct |
13 ms |
6656 KB |
Output is correct |
70 |
Correct |
13 ms |
6656 KB |
Output is correct |
71 |
Correct |
13 ms |
6912 KB |
Output is correct |
72 |
Correct |
14 ms |
6656 KB |
Output is correct |
73 |
Correct |
14 ms |
6656 KB |
Output is correct |
74 |
Correct |
11 ms |
6912 KB |
Output is correct |
75 |
Correct |
13 ms |
6656 KB |
Output is correct |
76 |
Correct |
13 ms |
6912 KB |
Output is correct |
77 |
Correct |
14 ms |
6912 KB |
Output is correct |
78 |
Correct |
14 ms |
6656 KB |
Output is correct |
79 |
Correct |
13 ms |
6912 KB |
Output is correct |
80 |
Correct |
13 ms |
6912 KB |
Output is correct |
81 |
Correct |
13 ms |
6656 KB |
Output is correct |
82 |
Correct |
13 ms |
6912 KB |
Output is correct |
83 |
Correct |
13 ms |
6912 KB |
Output is correct |
84 |
Correct |
14 ms |
6656 KB |
Output is correct |
85 |
Correct |
13 ms |
6688 KB |
Output is correct |
86 |
Correct |
13 ms |
6656 KB |
Output is correct |
87 |
Correct |
13 ms |
6656 KB |
Output is correct |
88 |
Correct |
13 ms |
6656 KB |
Output is correct |
89 |
Correct |
13 ms |
6656 KB |
Output is correct |
90 |
Correct |
13 ms |
6656 KB |
Output is correct |
91 |
Correct |
13 ms |
6912 KB |
Output is correct |
92 |
Correct |
13 ms |
6912 KB |
Output is correct |
93 |
Correct |
13 ms |
6912 KB |
Output is correct |
94 |
Correct |
13 ms |
6912 KB |
Output is correct |
95 |
Correct |
14 ms |
6656 KB |
Output is correct |
96 |
Correct |
14 ms |
6912 KB |
Output is correct |
97 |
Correct |
14 ms |
6912 KB |
Output is correct |
98 |
Correct |
14 ms |
6656 KB |
Output is correct |
99 |
Correct |
13 ms |
6656 KB |
Output is correct |
100 |
Correct |
13 ms |
6656 KB |
Output is correct |
101 |
Correct |
13 ms |
6912 KB |
Output is correct |
102 |
Correct |
13 ms |
6656 KB |
Output is correct |
103 |
Correct |
13 ms |
6912 KB |
Output is correct |
104 |
Correct |
13 ms |
6656 KB |
Output is correct |
105 |
Correct |
13 ms |
6656 KB |
Output is correct |
106 |
Correct |
13 ms |
6912 KB |
Output is correct |
107 |
Correct |
14 ms |
6656 KB |
Output is correct |
108 |
Correct |
13 ms |
6912 KB |
Output is correct |
109 |
Correct |
13 ms |
6656 KB |
Output is correct |
110 |
Correct |
13 ms |
6656 KB |
Output is correct |
111 |
Correct |
15 ms |
7008 KB |
Output is correct |
112 |
Correct |
15 ms |
6912 KB |
Output is correct |
113 |
Correct |
13 ms |
6656 KB |
Output is correct |
114 |
Correct |
16 ms |
6656 KB |
Output is correct |
115 |
Correct |
13 ms |
6656 KB |
Output is correct |
116 |
Correct |
13 ms |
6656 KB |
Output is correct |
117 |
Correct |
14 ms |
6912 KB |
Output is correct |
118 |
Correct |
13 ms |
6656 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
697 ms |
43272 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |