# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
927538 |
2024-02-15T03:04:37 Z |
CDuong |
Stray Cat (JOI20_stray) |
C++17 |
|
26 ms |
15020 KB |
#include "Anthony.h"
#include<bits/stdc++.h>
using namespace std;
namespace {
int chain[] = {0, 0, 1, 0, 1, 1};
}
vector<int> Mark(int N, int M, int A, int B, vector<int> U, vector<int> V) {
vector<vector<int>> G(N);
for (int i = 0; i < M; ++i) {
G[U[i]].emplace_back(V[i]);
G[V[i]].emplace_back(U[i]);
}
vector<int> dis(N, INT_MAX), color(N);
queue<int> q;
dis[0] = 0; q.emplace(0);
while (not q.empty()) {
int u = q.front(); q.pop();
for (int v : G[u]) if (dis[v] > dis[u] + 1) {
if (A == 2) {
if (u == 0) color[v] = 0;
else if ((int)G[u].size() >= 3) color[v] = !chain[color[u]];
else color[v] = (color[u] + 1) % 6;
}
dis[v] = dis[u] + 1;
q.emplace(v);
}
}
vector<int> res(M);
for (int i = 0; i < M; ++i) {
int u, v;
tie(u, v) = tie(U[i], V[i]);
if (dis[u] > dis[v]) swap(u, v);
if (A == 2) res[i] = chain[color[v]];
else res[i] = dis[u] % 3;
}
return res;
}
#include "Catherine.h"
#include<bits/stdc++.h>
using namespace std;
namespace {
int A, B;
int last = -1;
bool flag = false;
vector<int> vec;
vector<int> chain = {0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0};
} // namespace
void Init(int A, int B) {
::A = A;
::B = B;
}
int Move(vector<int> cnt) {
if (A != 2) {
if (last != -1) ++cnt[last];
if (cnt[0] == 0) return last = 1;
if (cnt[0] == 1) return last = 2;
if (cnt[0] == 2) return last = 0;
}
int deg = (last != -1);
for (int i = 0; i < 2; ++i) deg += cnt[i];
if (deg == 2) {
if (flag) {
for (int i = 0; i < 2; ++i) if (cnt[i] == 1) return last = i;
}
for (int i = 0; i < 2; ++i) {
for (int _ = 0; _ < cnt[i]; ++_) vec.emplace_back(i);
}
if ((int)vec.size() == 5) {
flag = true;
bool way = false;
for (int i = 0; i <= (int)chain.size() - (int)vec.size(); ++i) {
int ccnt = 0;
for (int j = 0; j < (int)vec.size(); ++j) ccnt += vec[j] == chain[i + j];
way |= ccnt == (int)vec.size();
}
if (way) return -1;
for (int i = 0; i < 2; ++i) if (cnt[i] == 1) return last = i;
}
else return last = vec.back();
}
else {
flag = true;
if (last != -1) ++cnt[last];
for (int i = 0; i < 2; ++i) if (cnt[i] == 1) {
if (last == i) return -1;
else return last = i;
}
}
}
Compilation message
Catherine.cpp: In function 'int Move(std::vector<int>)':
Catherine.cpp:59:1: warning: control reaches end of non-void function [-Wreturn-type]
59 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
26 ms |
15020 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
26 ms |
15020 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
24 ms |
12716 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
24 ms |
12716 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
1052 KB |
Wrong Answer [3] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
22 ms |
10644 KB |
Wrong Answer [3] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
22 ms |
10676 KB |
Wrong Answer [3] |
2 |
Halted |
0 ms |
0 KB |
- |