#include<bits/stdc++.h>
#include "Alicelib.h"
#define pii pair<int, int>
#define pll pair<long long, long long>
#define ll long long
#define ld long double
#define st first
#define nd second
#define pb push_back
#define INF INT_MAX
using namespace std;
int cnt = 0;
void Alice(int N, int M, int A[], int B[]) {
int binarycount = 0;
for (int i = 1; i <= N; ++i) {
binarycount += __builtin_popcount(i);
}
InitG(N+12, N+M+binarycount+10);
for (int i = 0; i < M; ++i) {
MakeG(cnt++, A[i], B[i]);
}
for (int i = 0; i < N; ++i) {
MakeG(cnt++, N, i);
}
MakeG(cnt++, N+1, N);
for (int i = N+2; i < N+11; ++i) {
MakeG(cnt++, i, i+1);
}
for (int i = 1; i <= N; ++i) {
for (int j = 0; j < 10; ++j) {
if (i & (1<<j)) MakeG(cnt++, i-1, N+2+j);
}
}
}
#include<bits/stdc++.h>
#include "Boblib.h"
#define pii pair<int, int>
#define pll pair<long long, long long>
#define ll long long
#define ld long double
#define st first
#define nd second
#define pb push_back
#define INF INT_MAX
using namespace std;
vector<int> adj[1050];
int unmap[1050];
int bit[11];
bool part[1050];
int deg[1050];
set<int> sbit;
void findbit(int i) {
if (i == 9) return;
for (auto j : adj[bit[i]]) {
if (!sbit.count(j) && !part[j]) {
bit[i+1] = j;
sbit.insert(j);
break;
}
}
findbit(i+1);
}
void Bob(int V, int U, int C[], int D[]) {
int binarycount = 0;
memset(unmap, -1, sizeof(unmap));
for (int i = 1; i <= (V-12); ++i) {
binarycount += __builtin_popcount(i);
}
int N = V-12, M = U-V+2-binarycount;
InitMap(N, M);
for (int i = 0; i < V; ++i) {
adj[C[i]].pb(D[i]);
adj[D[i]].pb(C[i]);
deg[C[i]]++, deg[D[i]]++;
}
int key, ckey;
for (int i = 0; i < V; ++i) {
if (deg[i] == 1 && deg[adj[i][0]] == N+1) {
key = adj[i][0];
ckey = i;
}
}
for (auto i : adj[key]) {
if (i != ckey) part[i] = 1;
}
vector<int> edge;
for (int i = 0; i < V; ++i) {
if (i == key || i == ckey) continue;
if (!part[i]) {
int cnt = 0;
for (auto j : adj[i]) {
if (!part[j]) cnt++;
}
if (cnt == 1) edge.pb(i);
}
}
if (deg[edge[0]] > deg[edge[1]]) bit[0] = edge[0];
else bit[0] = edge[1];
sbit.insert(bit[0]);
findbit(0);
for (int i = 0; i < V; ++i) {
if (i == key || i == ckey) continue;
if (sbit.count(i)) continue;
for (auto k : adj[i]) {
for (int j = 0; j < 10; ++j) {
// if (k == bit[j]) unmap[i] += (1<<j);
}
}
}
for (int i = 0; i < U; ++i) {
if (unmap[C[i]] == -1) continue;
if (unmap[D[i]] == -1) continue;
MakeMap(unmap[D[i]], unmap[C[i]]);
}
}
Compilation message
Bob.cpp: In function 'void Bob(int, int, int*, int*)':
Bob.cpp:78:19: warning: unused variable 'k' [-Wunused-variable]
78 | for (auto k : adj[i]) {
| ^
Bob.cpp:45:9: warning: 'key' may be used uninitialized in this function [-Wmaybe-uninitialized]
45 | int key, ckey;
| ^~~
Bob.cpp:54:9: warning: 'ckey' may be used uninitialized in this function [-Wmaybe-uninitialized]
54 | if (i != ckey) part[i] = 1;
| ^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
4612 KB |
Wrong Answer [17] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
4612 KB |
Wrong Answer [17] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
509 ms |
16576 KB |
Wrong Answer [17] |
2 |
Halted |
0 ms |
0 KB |
- |