#include "Anthony.h"
#include <bits/stdc++.h>
using namespace std;
namespace {
const int N = 20'000;
int n, m, a, b, h[N + 10], mark[N + 10];
vector<pair<int, int>> adj[N + 10];
vector<int> vec = {0, 0, 1, 1, 0, 1};
void readInput(int N, int M, int A, int B, std::vector<int> U, std::vector<int> V) {
n = N;
m = M;
a = A;
b = B;
for (int i = 1; i <= m; i++) {
int u = U[i - 1] + 1, v = V[i - 1] + 1;
adj[u].push_back({v, i});
adj[v].push_back({u, i});
}
}
void BFS() {
queue<int> qu;
qu.push(1);
mark[1] = true;
while (!qu.empty()) {
int u = qu.front();
qu.pop();
for (auto [v, id]: adj[u])
if (!mark[v]) {
h[v] = h[u] + 1;
mark[v] = true;
qu.push(v);
}
}
}
void solve() {
BFS();
}
} std::vector<int> Mark(int N, int M, int A, int B, std::vector<int> U, std::vector<int> V) {
readInput(N, M, A, B, U, V);
//cout << "alo " << endl;
solve();
vector<int> x;
for (int i = 1; i <= m; i++) {
int u = U[i - 1] + 1, v = V[i - 1] + 1;
x.push_back((h[u] != h[v]? max(h[u], h[v]) % 3: (h[u] + 1) % 3));
}
return x;
}
#include "Catherine.h"
#include <bits/stdc++.h>
using namespace std;
namespace {
const int T = 6;
const int A = 2;
deque<int> dq[10];
int a, b;
int check, cntCheck, goBack;
int solveit, cnt[10], deg[10], last, adj;
deque<int> vecCheck;
void calcDQ() {
vector<int> st = {0, 0, 1, 1, 0, 1};
for (int i = 0; i < T; i++)
dq[0].push_back(st[i]);
for (int i = 1; i < T; i++) {
dq[i] = dq[i - 1];
dq[i].push_back(dq[i].front());
dq[i].pop_front();
}
}
void init() {
calcDQ();
last = -1;
}
void initDeg(vector<int> x) {
adj = (last != -1);
for (int i = 0; i < a; i++) {
deg[i] = x[i];
cnt[i] = x[i];
adj += x[i];
}
if (last != -1)
cnt[last]++;
}
int checkSolveit() {
if (adj == 2) {
for (int i = 0; i < a; i++)
if (deg[i] == 1)
return i;
cout << 100 / 0 << endl;
}
if (last != -1 && cnt[last] == 1)
return -1;
for (int i = 0; i < a; i++)
if (cnt[i] == 1)
return i;
cout << 100 / 0 << endl;
}
bool goodPath() {
for (int i = 0; i < T; i++)
if (vecCheck == dq[i])
return true;
return false;
}
int checkMove() {
if (adj != 2)
solveit = true;
if (solveit)
return checkSolveit();
if (last == -1) {
cntCheck = T;
goBack = -1;
}
if (cntCheck) {
int one = (deg[0]? 0: 1);
vecCheck.push_back(one);
cntCheck--;
return one;
}
else if (goBack == -1) {
if (!goodPath()) {
//cout << "yes" << endl;
solveit = true;
return checkSolveit();
}
else {
solveit = true;
return -1;
}
}
if (goBack) {
goBack--;
return -1;
}
solveit = true;
return checkSolveit();
}
} void Init(int A, int B) {
a = A;
b = B;
init();
}
int Move(std::vector<int> y) {
//return 0;
initDeg(y);
int res;
vector<int> vec;
for (int i = 0; i < a; i++)
if (cnt[i])
vec.push_back(i);
if (vec.size() == 1)
res = vec[0];
else if ((vec[0] + 1) % 3 == vec[1])
res = vec[0];
else
res = vec[1];
last = (res == -1? last: res);
//cout << res << endl;
return res;
}
Compilation message (stderr)
# 2번째 컴파일 단계
Catherine.cpp: In function 'int {anonymous}::checkSolveit()':
Catherine.cpp:49:29: warning: division by zero [-Wdiv-by-zero]
49 | cout << 100 / 0 << endl;
| ~~~~^~~
Catherine.cpp:56:21: warning: division by zero [-Wdiv-by-zero]
56 | cout << 100 / 0 << endl;
| ~~~~^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |