#ifndef hwe
#include "Alicelib.h"
#endif
#include <bits/stdc++.h>
using namespace std;
#define popcount(n) (__builtin_popcountll((n)))
#define clz(n) (__builtin_clzll((n)))
#define ctz(n) (__builtin_ctzll((n)))
#define lg(n) (63 - __builtin_clzll((n)))
#define BIT(n, i) (((n) >> (i)) & 1ll)
#define MASK(i) (1ll << (i))
#define FLIP(n, i) ((n) ^ (1ll << (i)))
#define ON(n, i) ((n) | MASK(i))
#define OFF(n, i) ((n) & ~MASK(i))
#define Int __int128
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<long long, int> pli;
typedef pair<int, long long> pil;
typedef vector<pair<int, int>> vii;
typedef vector<pair<long long, long long>> vll;
typedef vector<pair<long long, int>> vli;
typedef vector<pair<int, long long>> vil;
template <class T1, class T2>
bool maximize(T1 &x, T2 y) {
if (x < y) {
x = y;
return true;
}
return false;
}
template <class T1, class T2>
bool minimize(T1 &x, T2 y) {
if (x > y) {
x = y;
return true;
}
return false;
}
template <class T>
void remove_duplicate(vector<T> &ve) {
sort (ve.begin(), ve.end());
ve.resize(unique(ve.begin(), ve.end()) - ve.begin());
}
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
template <class T> T random(T l, T r) {
return uniform_int_distribution<T>(l, r)(rng);
}
template <class T> T random(T r) {
return rng() % r;
}
const int N = 1e6 + 5;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
#ifdef hwe
void InitG(int v, int u) {
cerr << "Init G: " << v << ' ' << u << '\n';
}
void MakeG(int pos, int C, int D) {
cerr << "Make G: " << pos << ' ' << C << ' ' << D << '\n';
}
#endif
void Alice(int n, int m, int a[], int b[]) {
vii edges;
for (int i = 0; i < m; ++i) edges.emplace_back(a[i], b[i]);
// edge (bit node i, j) when BIT(j, i) == 0
for (int i = 0; i < 10; ++i) for (int j = 0; j < n; ++j) {
if (!BIT(j, i)) edges.emplace_back(n + i, j);
}
// connect all bit-nodes
for (int i = n; i + 1 < n + 12; ++i) edges.emplace_back(i, i + 1);
// create two unique nodes
for (int i = 0; i < n; ++i) edges.emplace_back(n + 10, i);
edges.emplace_back(n + 10, n + 11);
InitG(n + 12, edges.size());
for (int i = 0; i < edges.size(); ++i) MakeG(i, edges[i].fi, edges[i].se);
}
#ifdef hwe
signed main() {
cerr << '\n'; return 0;
}
#endif
#ifndef hwe
#include "Boblib.h"
#endif
#include <bits/stdc++.h>
using namespace std;
#define popcount(n) (__builtin_popcountll((n)))
#define clz(n) (__builtin_clzll((n)))
#define ctz(n) (__builtin_ctzll((n)))
#define lg(n) (63 - __builtin_clzll((n)))
#define BIT(n, i) (((n) >> (i)) & 1ll)
#define MASK(i) (1ll << (i))
#define FLIP(n, i) ((n) ^ (1ll << (i)))
#define ON(n, i) ((n) | MASK(i))
#define OFF(n, i) ((n) & ~MASK(i))
#define Int __int128
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<long long, int> pli;
typedef pair<int, long long> pil;
typedef vector<pair<int, int>> vii;
typedef vector<pair<long long, long long>> vll;
typedef vector<pair<long long, int>> vli;
typedef vector<pair<int, long long>> vil;
template <class T1, class T2>
bool maximize(T1 &x, T2 y) {
if (x < y) {
x = y;
return true;
}
return false;
}
template <class T1, class T2>
bool minimize(T1 &x, T2 y) {
if (x > y) {
x = y;
return true;
}
return false;
}
template <class T>
void remove_duplicate(vector<T> &ve) {
sort (ve.begin(), ve.end());
ve.resize(unique(ve.begin(), ve.end()) - ve.begin());
}
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
template <class T> T random(T l, T r) {
return uniform_int_distribution<T>(l, r)(rng);
}
template <class T> T random(T r) {
return rng() % r;
}
const int N = 1100 + 5;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
int cnt[N], ans[N];
vector<int> adj[N];
bitset<N> mark, in_chain;
#ifdef hwe
void InitMap(int n, int m) {
cerr << "Init map: " << n << ' ' << m << '\n';
}
void MakeMap(int a, int b) {
cerr << "Make map: " << a << ' ' << b << '\n';
}
#endif
void Bob(int v, int u, int C[], int D[]) {
int n = v - 12;
for (int i = 0; i < v; ++i) {
adj[i].clear(); ans[i] = MASK(10) - 1;
mark[i] = in_chain[i] = false;
}
for (int i = 0; i < u; ++i) {
adj[C[i]].emplace_back(D[i]);
adj[D[i]].emplace_back(C[i]);
}
int connect_with_all_non = -1;
for (int i = 0; i < v; ++i) {
if (adj[i].size() == n + 1) {
assert(connect_with_all_non == -1);
connect_with_all_non = i;
}
}
for (auto &x : adj[connect_with_all_non]) mark[x] = true;
vector<int> bitnodes;
for (int i = 0; i < v; ++i) if (!mark[i]) {
bitnodes.emplace_back(i);
}
for (int i = 0; i < 10; ++i) for (int j = 0; j < n; ++j) {
if (!BIT(j, i)) ++cnt[i];
}
int start = -1;
for (auto node : bitnodes) {
int counter = -1;
for (auto x : adj[node]) if (!mark[x]) ++counter;
if (counter == 1) {
start = node;
break;
}
}
vector<int> chain = {start}; int cur = start; in_chain[start] = true;
for (int _ = 0; _ < 11; ++_) {
for (auto x : adj[cur]) if (!mark[x] && !in_chain[x]) {
chain.emplace_back(x), in_chain[x] = true;
break;
}
}
auto valid_chain = [&](vector<int> chain) {
for (int i = 1; i + 1 < chain.size(); ++i)
if (adj[chain[i]].size() - 2 != cnt[i]) return false;
return adj[chain[0]].size() - 1 == cnt[0] && adj[chain.back()].size() - 1 == cnt[chain.size() - 1];
};
if (!valid_chain(chain)) reverse(chain.begin(), chain.end());
assert(valid_chain(chain));
for (int i = 0; i < chain.size(); ++i) {
for (auto &x : adj[chain[i]]) if (mark[x]) {
ans[x] = OFF(ans[x], i);
}
}
vii edges;
for (int i = 0; i < u; ++i) {
if (!mark[C[i]] || !mark[D[i]]) continue;
edges.emplace_back(ans[C[i]], ans[D[i]]);
}
InitMap(n, edges.size());
for (auto it : edges) MakeMap(it.fi, it.se);
}
#ifdef hwe
signed main() {
cerr << '\n'; return 0;
}
#endif
Compilation message
Alice.cpp: In function 'void Alice(int, int, int*, int*)':
Alice.cpp:98:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
98 | for (int i = 0; i < edges.size(); ++i) MakeG(i, edges[i].fi, edges[i].se);
| ~~^~~~~~~~~~~~~~
Bob.cpp: In function 'void Bob(int, int, int*, int*)':
Bob.cpp:98:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
98 | if (adj[i].size() == n + 1) {
| ~~~~~~~~~~~~~~^~~~~~~~
Bob.cpp: In lambda function:
Bob.cpp:134:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
134 | for (int i = 1; i + 1 < chain.size(); ++i)
| ~~~~~~^~~~~~~~~~~~~~
Bob.cpp:135:33: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
135 | if (adj[chain[i]].size() - 2 != cnt[i]) return false;
| ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
Bob.cpp:136:35: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
136 | return adj[chain[0]].size() - 1 == cnt[0] && adj[chain.back()].size() - 1 == cnt[chain.size() - 1];
| ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
Bob.cpp:136:77: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
136 | return adj[chain[0]].size() - 1 == cnt[0] && adj[chain.back()].size() - 1 == cnt[chain.size() - 1];
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Bob.cpp: In function 'void Bob(int, int, int*, int*)':
Bob.cpp:143:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
143 | for (int i = 0; i < chain.size(); ++i) {
| ~~^~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
3416 KB |
Wrong Answer [9] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
3416 KB |
Wrong Answer [9] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
295 ms |
15396 KB |
Wrong Answer [9] |
2 |
Halted |
0 ms |
0 KB |
- |