#include "Alicelib.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
struct chash
{
int operator()(int x) const
{
x ^= (x >> 20) ^ (x >> 12);
return x ^ (x >> 7) ^ (x >> 4);
}
int operator()(long long x) const
{
return x ^ (x >> 32);
}
};
template<typename T> using orderedset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename U> using hashtable = gp_hash_table<T, U, chash>;
template<class T>
void readi(T &x)
{
T input = 0;
bool negative = false;
char c = ' ';
while (c < '-')
{
c = getchar();
}
if (c == '-')
{
negative = true;
c = getchar();
}
while (c >= '0')
{
input = input * 10 + (c - '0');
c = getchar();
}
if (negative)
{
input = -input;
}
x = input;
}
template<class T>
void printi(T output)
{
if (output == 0)
{
putchar('0');
return;
}
if (output < 0)
{
putchar('-');
output = -output;
}
int aout[20];
int ilen = 0;
while(output)
{
aout[ilen] = ((output % 10));
output /= 10;
ilen++;
}
for (int i = ilen - 1; i >= 0; i--)
{
putchar(aout[i] + '0');
}
return;
}
template<class T>
void ckmin(T &a, T b)
{
a = min(a, b);
}
template<class T>
void ckmax(T &a, T b)
{
a = max(a, b);
}
template<class T>
T normalize(T x, T mod = 1000000007)
{
return (((x % mod) + mod) % mod);
}
#define y0 ___y0
#define y1 ___y1
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define debug(x) cerr << #x << " = " << x << endl;
const long double PI = 4.0 * atan(1.0);
const long double EPS = 1e-10;
#define MAGIC 347
#define SINF 10007
#define CO 1000007
#define INF 1000000007
#define BIG 1000000931
#define LARGE 1696969696967ll
#define GIANT 2564008813937411ll
#define LLINF 2696969696969696969ll
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
int N;
vector<pii> EDGE, EDGES;
void Alice(int n, int m, int a[], int b[])
{
N = n;
for (int i = 0; i < m; i++)
{
int r1 = rand() % m, r2 = rand() % m;
swap(a[r1], a[r2]);
swap(b[r1], b[r2]);
}
for (int i = 0; i < m; i++)
{
assert(0 <= a[i] && a[i] < N);
assert(0 <= b[i] && b[i] < N);
assert(a[i] != b[i]);
if (a[i] > b[i])
{
swap(a[i], b[i]);
}
EDGE.PB(MP(a[i], b[i]));
}
assert(N != 0);
for (int i = 0; i < EDGE.size(); i++)
{
int u = EDGE[i].fi, v = EDGE[i].se;
EDGES.PB(MP(u, v));
}
for (int i = 0; i < N; i++)
{
for (int j = 0; j < 10; j++)
{
if ((i & (1 << j)))
{
EDGES.PB(MP(i, N + j));
}
}
}
for (int i = 0; i < 10; i++)
{
for (int j = 0; j < i; j++)
{
EDGES.PB(MP(N + j, N + i));
}
}
for (int i = 0; i < N + 10; i++)
{
EDGES.PB(MP(i, N + 10));
}
//N + 10 is friends with everybody but N+11
//N+11 is friends with all the guys in the loop
for (int i = N; i < N + 10; i++)
{
EDGES.PB(MP(i, N + 11));
}
InitG(N + 12, EDGES.size());
for (int i = 0; i < EDGES.size(); i++)
{
assert(EDGES[i].fi != EDGES[i].se);
MakeG(i, EDGES[i].fi, EDGES[i].se);
}
return;
}
#include "Boblib.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
struct chash
{
int operator()(int x) const
{
x ^= (x >> 20) ^ (x >> 12);
return x ^ (x >> 7) ^ (x >> 4);
}
int operator()(long long x) const
{
return x ^ (x >> 32);
}
};
template<typename T> using orderedset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename U> using hashtable = gp_hash_table<T, U, chash>;
template<class T>
void readi(T &x)
{
T input = 0;
bool negative = false;
char c = ' ';
while (c < '-')
{
c = getchar();
}
if (c == '-')
{
negative = true;
c = getchar();
}
while (c >= '0')
{
input = input * 10 + (c - '0');
c = getchar();
}
if (negative)
{
input = -input;
}
x = input;
}
template<class T>
void printi(T output)
{
if (output == 0)
{
putchar('0');
return;
}
if (output < 0)
{
putchar('-');
output = -output;
}
int aout[20];
int ilen = 0;
while(output)
{
aout[ilen] = ((output % 10));
output /= 10;
ilen++;
}
for (int i = ilen - 1; i >= 0; i--)
{
putchar(aout[i] + '0');
}
return;
}
template<class T>
void ckmin(T &a, T b)
{
a = min(a, b);
}
template<class T>
void ckmax(T &a, T b)
{
a = max(a, b);
}
template<class T>
T normalize(T x, T mod = 1000000007)
{
return (((x % mod) + mod) % mod);
}
#define y0 ___y0
#define y1 ___y1
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define debug(x) cerr << #x << " = " << x << endl;
const long double PI = 4.0 * atan(1.0);
const long double EPS = 1e-10;
#define MAGIC 347
#define SINF 10007
#define CO 1000007
#define INF 1000000007
#define BIG 1000000931
#define LARGE 1696969696967ll
#define GIANT 2564008813937411ll
#define LLINF 2696969696969696969ll
#define MAXN 1313
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
int V;
vector<pii> edges, isbits;
vector<int> edge[MAXN];
int bt[MAXN], id[MAXN];
bool isbit[MAXN], inlone[MAXN];
int lone, control;
void Bob(int n, int m, int a[], int b[])
{
V = n;
for (int i = 0; i < m; i++)
{
assert(0 <= a[i] && a[i] < n);
assert(0 <= b[i] && b[i] < n);
edge[b[i]].PB(a[i]);
}
int freq = 0;
for (int i = 0; i < V; i++)
{
if (edge[i].size() == V - 2)
{
lone = i;
freq++;
}
}
assert(freq == 0);
for (int x : edge[lone])
{
inlone[x] = true;
}
for (int i = 0; i < V; i++)
{
if (i != lone && !inlone[i])
{
control = i;
}
}
for (int x : edge[control])
{
isbits.PB(MP(x, 0));
isbit[x] = true;
}
for (pii &p : isbits)
{
int u = p.fi;
for (int v : edge[u])
{
if (isbit[v])
{
p.se++;
}
}
bt[p.se]= u;
}
for (int i = 0; i < 10; i++)
{
int u = bt[i];
for (int v : edge[u])
{
if (isbit[v] || v == control || v == lone)
{
continue;
}
id[v] += (1 << i);
}
}
for (int u = 0; u < V; u++)
{
if (isbit[u] || u == control || u == lone)
{
continue;
}
for (int v : edge[u])
{
if (isbit[v] || v == control || v == lone)
{
continue;
}
edges.PB(MP(id[u], id[v]));
}
}
for (pii x : edges)
{
assert(0 <= x.fi && x.fi < V - 12);
assert(0 <= x.se && x.se < V - 12);
}
InitMap(V - 12, edges.size());
for (pii x : edges)
{
assert(x.fi != x.se);
MakeMap(x.fi, x.se);
}
return;
}
Compilation message
Alice.cpp: In function 'void Alice(int, int, int*, int*)':
Alice.cpp:148:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < EDGE.size(); i++)
~~^~~~~~~~~~~~~
Alice.cpp:181:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < EDGES.size(); i++)
~~^~~~~~~~~~~~~~
Bob.cpp: In function 'void Bob(int, int, int*, int*)':
Bob.cpp:144:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (edge[i].size() == V - 2)
~~~~~~~~~~~~~~~^~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
18 ms |
6896 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
18 ms |
6896 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
788 ms |
38776 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |