# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
220274 |
2020-04-07T13:42:09 Z |
WLZ |
Stray Cat (JOI20_stray) |
C++14 |
|
87 ms |
17012 KB |
#include "Anthony.h"
#include <bits/stdc++.h>
using namespace std;
namespace {
const vector<int> period = {0, 1, 0, 0, 1, 1};
struct edge {
int from, to, idx;
};
vector< vector<edge> > g;
vector<int> solve1234(int N, int M, vector<int> U, vector<int> V) {
queue<int> q;
q.push(0);
vector<int> dist(N, -1), ans(M, -1);
dist[0] = 0;
while (!q.empty()) {
int u = q.front(); q.pop();
for (auto& e : g[u]) {
if (dist[e.to] == -1) {
dist[e.to] = dist[u] + 1;
q.push(e.to);
}
}
}
for (int i = 0; i < M; i++) {
ans[i] = min(dist[U[i]], dist[V[i]]) % 3;
}
return ans;
}
vector<int> solve567(int N, int M, vector<int> U, vector<int> V) {
vector<int> prev(N, 1), was(N, 0), len(N, 0), ans(M, -1);
queue<int> q; q.push(0);
was[0] = 1;
while (!q.empty()) {
int u = q.front(); q.pop();
for (auto& e : g[u]) {
if (!was[e.to]) {
if ((int) g[u].size() == 2 || u == 0) {
len[e.to] = len[u] + 1;
ans[e.idx] = period[len[u] % 6];
} else {
ans[e.idx] = !prev[u];
}
q.push(e.to);
was[e.to] = 1;
prev[e.to] = ans[e.idx];
}
}
}
return ans;
}
}
vector<int> Mark(int N, int M, int A, int B, vector<int> U, vector<int> V) {
g.resize(N);
for (int i = 0; i < M; i++) {
g[U[i]].push_back({U[i], V[i], i});
g[V[i]].push_back({V[i], U[i], i});
}
if (A >= 3) {
return solve1234(N, M, U, V);
} else {
return solve567(N, M, U, V);
}
}
#include "Catherine.h"
#include <bits/stdc++.h>
using namespace std;
namespace {
const vector<int> period = {0, 1, 0, 0, 1, 1};
vector<int> cur;
int A, B, start = 1, rev = 0;
}
void Init(int A, int B) {
::A = A; ::B = B;
}
int Move(vector<int> y) {
if (A >= 3) {
for (int i = 0; i < 3; i++) {
if (y[i] > 0 && y[(i + 1) % 3] > 0) {
return i;
}
}
for (int i = 0; i < 3; i++) {
if (y[i] > 0) {
return i;
}
}
} else {
if (y[0] > 1 && y[1] > 0) {
start = 0;
return 1;
}
if (y[0] > 1 && y[1] > 0) {
start = 0;
return 0;
}
if (y[0] == 0 && y[1] == 0) {
start = 0;
return -1;
}
if (start) {
if (y[0] > 0 && y[1] > 0 && !cur.empty()) {
start = 0;
return !cur.back();
}
for (int i = 0; i < 2; i++) {
if (y[i] > 0) {
if (cur.empty()) {
if (y[i] > 1) {
cur.push_back(i);
} else {
cur.push_back(!i);
}
}
cur.push_back(i);
break;
}
}
if ((int) cur.size() == 5) {
start = 0;
for (int i = 0; i < 6; i++) {
int match = 1;
for (int j = 0; j < 5; j++) {
if (period[(i + j) % 6] != cur[j]) {
match = 0;
break;
}
}
if (match) {
rev = 1;
cur.pop_back();
cur.pop_back();
break;
}
}
}
if (!rev) {
return cur.back();
}
} else {
if (y[0] > 0) {
return 0;
}
return 1;
}
}
}
Compilation message
Catherine.cpp: In function 'int Move(std::vector<int>)':
Catherine.cpp:87:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
59 ms |
15884 KB |
Output is correct |
2 |
Correct |
9 ms |
908 KB |
Output is correct |
3 |
Correct |
47 ms |
15468 KB |
Output is correct |
4 |
Correct |
74 ms |
16972 KB |
Output is correct |
5 |
Correct |
86 ms |
17012 KB |
Output is correct |
6 |
Correct |
55 ms |
15748 KB |
Output is correct |
7 |
Correct |
70 ms |
15844 KB |
Output is correct |
8 |
Correct |
67 ms |
16500 KB |
Output is correct |
9 |
Correct |
71 ms |
16444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
59 ms |
15884 KB |
Output is correct |
2 |
Correct |
9 ms |
908 KB |
Output is correct |
3 |
Correct |
47 ms |
15468 KB |
Output is correct |
4 |
Correct |
74 ms |
16972 KB |
Output is correct |
5 |
Correct |
86 ms |
17012 KB |
Output is correct |
6 |
Correct |
55 ms |
15748 KB |
Output is correct |
7 |
Correct |
70 ms |
15844 KB |
Output is correct |
8 |
Correct |
67 ms |
16500 KB |
Output is correct |
9 |
Correct |
71 ms |
16444 KB |
Output is correct |
10 |
Correct |
54 ms |
13884 KB |
Output is correct |
11 |
Correct |
73 ms |
13748 KB |
Output is correct |
12 |
Correct |
57 ms |
13860 KB |
Output is correct |
13 |
Correct |
65 ms |
13896 KB |
Output is correct |
14 |
Correct |
57 ms |
14036 KB |
Output is correct |
15 |
Correct |
63 ms |
14580 KB |
Output is correct |
16 |
Correct |
64 ms |
16428 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
62 ms |
13692 KB |
Output is correct |
2 |
Correct |
15 ms |
772 KB |
Output is correct |
3 |
Correct |
52 ms |
13180 KB |
Output is correct |
4 |
Correct |
81 ms |
14720 KB |
Output is correct |
5 |
Correct |
69 ms |
14700 KB |
Output is correct |
6 |
Correct |
87 ms |
13412 KB |
Output is correct |
7 |
Correct |
66 ms |
13436 KB |
Output is correct |
8 |
Correct |
70 ms |
14212 KB |
Output is correct |
9 |
Correct |
71 ms |
14268 KB |
Output is correct |
10 |
Correct |
74 ms |
14000 KB |
Output is correct |
11 |
Correct |
76 ms |
14020 KB |
Output is correct |
12 |
Correct |
68 ms |
14012 KB |
Output is correct |
13 |
Correct |
60 ms |
13940 KB |
Output is correct |
14 |
Correct |
76 ms |
14268 KB |
Output is correct |
15 |
Correct |
72 ms |
14116 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
62 ms |
13692 KB |
Output is correct |
2 |
Correct |
15 ms |
772 KB |
Output is correct |
3 |
Correct |
52 ms |
13180 KB |
Output is correct |
4 |
Correct |
81 ms |
14720 KB |
Output is correct |
5 |
Correct |
69 ms |
14700 KB |
Output is correct |
6 |
Correct |
87 ms |
13412 KB |
Output is correct |
7 |
Correct |
66 ms |
13436 KB |
Output is correct |
8 |
Correct |
70 ms |
14212 KB |
Output is correct |
9 |
Correct |
71 ms |
14268 KB |
Output is correct |
10 |
Correct |
74 ms |
14000 KB |
Output is correct |
11 |
Correct |
76 ms |
14020 KB |
Output is correct |
12 |
Correct |
68 ms |
14012 KB |
Output is correct |
13 |
Correct |
60 ms |
13940 KB |
Output is correct |
14 |
Correct |
76 ms |
14268 KB |
Output is correct |
15 |
Correct |
72 ms |
14116 KB |
Output is correct |
16 |
Correct |
53 ms |
11924 KB |
Output is correct |
17 |
Correct |
47 ms |
11920 KB |
Output is correct |
18 |
Correct |
49 ms |
12004 KB |
Output is correct |
19 |
Correct |
51 ms |
12020 KB |
Output is correct |
20 |
Correct |
57 ms |
12408 KB |
Output is correct |
21 |
Correct |
54 ms |
12284 KB |
Output is correct |
22 |
Correct |
59 ms |
14288 KB |
Output is correct |
23 |
Correct |
50 ms |
12128 KB |
Output is correct |
24 |
Correct |
52 ms |
12140 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
1120 KB |
Output is correct |
2 |
Correct |
5 ms |
936 KB |
Output is correct |
3 |
Correct |
10 ms |
1120 KB |
Output is correct |
4 |
Correct |
10 ms |
1256 KB |
Output is correct |
5 |
Correct |
10 ms |
1048 KB |
Output is correct |
6 |
Correct |
10 ms |
1132 KB |
Output is correct |
7 |
Correct |
10 ms |
1040 KB |
Output is correct |
8 |
Correct |
10 ms |
1144 KB |
Output is correct |
9 |
Correct |
10 ms |
1120 KB |
Output is correct |
10 |
Correct |
10 ms |
1040 KB |
Output is correct |
11 |
Correct |
10 ms |
1124 KB |
Output is correct |
12 |
Incorrect |
10 ms |
1200 KB |
Wrong Answer [6] |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
47 ms |
11780 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
48 ms |
11804 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |