# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
939328 |
2024-03-06T09:20:25 Z |
Pring |
Stray Cat (JOI20_stray) |
C++14 |
|
47 ms |
17320 KB |
#include <bits/stdc++.h>
#include "Anthony.h"
using namespace std;
const string dbmc = "\033[1;38;2;57;197;187m", dbrs = "\033[0m";
#define fs first
#define sc second
#define mp make_pair
#define FOR(i, j, k) for (int i = j, Z = k; i < Z; i++)
typedef pair<int, int> pii;
namespace {
const int MXN = 20005;
int n, m, A, B;
vector<int> eu, ev;
vector<int> eid[MXN];
int deg[MXN];
namespace NSA {
int d[MXN];
vector<int> tag;
void BFS(int sr) {
fill(d, d + n, -1);
queue<pii> q;
q.push(mp(0, sr));
while (q.size()) {
auto [dep, id] = q.front();
q.pop();
if (d[id] != -1) continue;
d[id] = dep;
for (auto &e : eid[id]) {
int i = eu[e] ^ ev[e] ^ id;
if (d[i] != -1) continue;
q.push(mp(dep + 1, i));
}
}
}
vector<int> Mark() {
BFS(0);
tag.resize(m);
FOR(i, 0, m) {
if (d[eu[i]] == d[ev[i]]) tag[i] = d[eu[i]] % 3;
else tag[i] = min(d[eu[i]], d[ev[i]]) % 3;
}
return tag;
}
}
namespace NSB {
const int mans[6] = {1, 1, 0, 0, 1, 0};
const int mnxt[6] = {2, 2, 0, 0, 2, 0};
vector<int> tag;
void BFS(int sr) {
queue<pii> q;
for (auto &e : eid[sr]) q.push(mp(e, eu[e] ^ ev[e] ^ sr));
while (q.size()) {
auto [ep, id] = q.front();
q.pop();
int nxt = (deg[id] == 2 ? (tag[ep] + 1) % 6 : mnxt[tag[ep]]);
for (auto &e : eid[id]) {
if (e == ep) continue;
int i = eu[e] ^ ev[e] ^ id;
tag[e] = nxt;
q.push(mp(e, i));
}
}
}
vector<int> Mark() {
tag.resize(m);
BFS(0);
FOR(i, 0, m) tag[i] = mans[tag[i]];
return tag;
}
}
}
vector<int> Mark(int _n, int _m, int _a, int _b, vector<int> _eu, vector<int> _ev) {
n = _n;
m = _m;
A = _a;
B = _b;
eu = _eu;
ev = _ev;
FOR(i, 0, m) {
eid[eu[i]].push_back(i);
eid[ev[i]].push_back(i);
deg[eu[i]]++;
deg[ev[i]]++;
}
return (A >= 3 ? NSA::Mark() : NSB::Mark());
}
#include <bits/stdc++.h>
#include "Catherine.h"
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define FOR(i, j, k) for (int i = j, Z = k; i < Z; i++)
typedef pair<int, int> pii;
namespace {
int A, B;
namespace NSA {
int Move(vector<int> &y) {
int a = y[0], b = y[1], c = y[2];
int cnt = (a != 0) + (b != 0) + (c != 0);
if (cnt == 1) return (a ? 0 : (b ? 1 : 2));
return (a == 0 ? 1 : (b == 0 ? 2 : 0));
}
}
namespace NSB {
bool confused;
int lst;
string go;
// 110010
bool far() {
string t = "110010110010";
FOR(i, 0, 6) if (t.substr(i, 5) == go) return true;
return false;
}
int Move(vector<int> &y) {
int deg = y[0] + y[1];
if (lst == -1) {
if (deg == 1) {
confused = false;
return (lst = (y[0] ? 0 : 1));
}
if (deg > 2) {
confused = false;
return (lst = (y[0] == 1 ? 0 : 1));
}
if (y[0] == 1) {
go = "01";
return (lst = 1);
}
if (y[0]) {
go = "00";
return (lst = 0);
}
go = "11";
return (lst = 1);
}
if (confused) {
if (deg == 0) {
confused = false;
return -1;
}
if (deg > 1) {
if (y[0] && y[1]) {
confused = false;
return (lst = (lst ^ 1));
}
}
go.push_back(y[0] ? '0' : '1');
if (go.size() == 5) {
confused = false;
if (far()) return -1;
}
return (lst = (y[0] ? 0 : 1));
}
if (deg > 1) return (lst = (lst ^ 1));
return (lst = (y[0] ? 0 : 1));
}
}
}
void Init(int _a, int _b) {
A = _a;
B = _b;
NSB::confused = true;
NSB::lst = -1;
}
int Move(vector<int> y) {
return (A >= 3 ? NSA::Move(y) : NSB::Move(y));
}
Compilation message
Anthony.cpp: In function 'void {anonymous}::NSA::BFS(int)':
Anthony.cpp:29:22: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
29 | auto [dep, id] = q.front();
| ^
Anthony.cpp: In function 'void {anonymous}::NSB::BFS(int)':
Anthony.cpp:61:22: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
61 | auto [ep, id] = q.front();
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
39 ms |
16196 KB |
Output is correct |
2 |
Correct |
1 ms |
1312 KB |
Output is correct |
3 |
Correct |
26 ms |
15552 KB |
Output is correct |
4 |
Correct |
44 ms |
17188 KB |
Output is correct |
5 |
Correct |
36 ms |
17320 KB |
Output is correct |
6 |
Correct |
31 ms |
16204 KB |
Output is correct |
7 |
Correct |
27 ms |
16164 KB |
Output is correct |
8 |
Correct |
41 ms |
16716 KB |
Output is correct |
9 |
Correct |
32 ms |
16656 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
39 ms |
16196 KB |
Output is correct |
2 |
Correct |
1 ms |
1312 KB |
Output is correct |
3 |
Correct |
26 ms |
15552 KB |
Output is correct |
4 |
Correct |
44 ms |
17188 KB |
Output is correct |
5 |
Correct |
36 ms |
17320 KB |
Output is correct |
6 |
Correct |
31 ms |
16204 KB |
Output is correct |
7 |
Correct |
27 ms |
16164 KB |
Output is correct |
8 |
Correct |
41 ms |
16716 KB |
Output is correct |
9 |
Correct |
32 ms |
16656 KB |
Output is correct |
10 |
Correct |
36 ms |
14060 KB |
Output is correct |
11 |
Correct |
26 ms |
14100 KB |
Output is correct |
12 |
Correct |
25 ms |
14148 KB |
Output is correct |
13 |
Correct |
34 ms |
14016 KB |
Output is correct |
14 |
Correct |
28 ms |
14412 KB |
Output is correct |
15 |
Correct |
36 ms |
14780 KB |
Output is correct |
16 |
Correct |
32 ms |
16776 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
27 ms |
13764 KB |
Output is correct |
2 |
Correct |
1 ms |
1308 KB |
Output is correct |
3 |
Correct |
28 ms |
13312 KB |
Output is correct |
4 |
Correct |
37 ms |
15124 KB |
Output is correct |
5 |
Correct |
33 ms |
15096 KB |
Output is correct |
6 |
Correct |
32 ms |
13856 KB |
Output is correct |
7 |
Correct |
28 ms |
13820 KB |
Output is correct |
8 |
Correct |
37 ms |
14412 KB |
Output is correct |
9 |
Correct |
33 ms |
14328 KB |
Output is correct |
10 |
Correct |
31 ms |
14304 KB |
Output is correct |
11 |
Correct |
30 ms |
14288 KB |
Output is correct |
12 |
Correct |
31 ms |
14180 KB |
Output is correct |
13 |
Correct |
32 ms |
14112 KB |
Output is correct |
14 |
Correct |
34 ms |
14460 KB |
Output is correct |
15 |
Correct |
38 ms |
14428 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
27 ms |
13764 KB |
Output is correct |
2 |
Correct |
1 ms |
1308 KB |
Output is correct |
3 |
Correct |
28 ms |
13312 KB |
Output is correct |
4 |
Correct |
37 ms |
15124 KB |
Output is correct |
5 |
Correct |
33 ms |
15096 KB |
Output is correct |
6 |
Correct |
32 ms |
13856 KB |
Output is correct |
7 |
Correct |
28 ms |
13820 KB |
Output is correct |
8 |
Correct |
37 ms |
14412 KB |
Output is correct |
9 |
Correct |
33 ms |
14328 KB |
Output is correct |
10 |
Correct |
31 ms |
14304 KB |
Output is correct |
11 |
Correct |
30 ms |
14288 KB |
Output is correct |
12 |
Correct |
31 ms |
14180 KB |
Output is correct |
13 |
Correct |
32 ms |
14112 KB |
Output is correct |
14 |
Correct |
34 ms |
14460 KB |
Output is correct |
15 |
Correct |
38 ms |
14428 KB |
Output is correct |
16 |
Correct |
26 ms |
12300 KB |
Output is correct |
17 |
Correct |
27 ms |
12212 KB |
Output is correct |
18 |
Correct |
28 ms |
12032 KB |
Output is correct |
19 |
Correct |
28 ms |
12160 KB |
Output is correct |
20 |
Correct |
27 ms |
12716 KB |
Output is correct |
21 |
Correct |
27 ms |
12672 KB |
Output is correct |
22 |
Correct |
39 ms |
14548 KB |
Output is correct |
23 |
Correct |
30 ms |
12372 KB |
Output is correct |
24 |
Correct |
27 ms |
12352 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1564 KB |
Output is correct |
2 |
Correct |
1 ms |
1296 KB |
Output is correct |
3 |
Correct |
2 ms |
1564 KB |
Output is correct |
4 |
Correct |
3 ms |
1572 KB |
Output is correct |
5 |
Correct |
2 ms |
1564 KB |
Output is correct |
6 |
Correct |
2 ms |
1572 KB |
Output is correct |
7 |
Correct |
2 ms |
1572 KB |
Output is correct |
8 |
Correct |
2 ms |
1556 KB |
Output is correct |
9 |
Correct |
2 ms |
1568 KB |
Output is correct |
10 |
Correct |
2 ms |
1572 KB |
Output is correct |
11 |
Correct |
2 ms |
1572 KB |
Output is correct |
12 |
Correct |
2 ms |
1572 KB |
Output is correct |
13 |
Correct |
1 ms |
1564 KB |
Output is correct |
14 |
Correct |
2 ms |
1564 KB |
Output is correct |
15 |
Correct |
1 ms |
1564 KB |
Output is correct |
16 |
Correct |
2 ms |
1564 KB |
Output is correct |
17 |
Correct |
2 ms |
1572 KB |
Output is correct |
18 |
Correct |
2 ms |
1556 KB |
Output is correct |
19 |
Correct |
2 ms |
1568 KB |
Output is correct |
20 |
Correct |
2 ms |
1568 KB |
Output is correct |
21 |
Correct |
2 ms |
1572 KB |
Output is correct |
22 |
Correct |
2 ms |
1564 KB |
Output is correct |
23 |
Correct |
2 ms |
1572 KB |
Output is correct |
24 |
Correct |
2 ms |
1572 KB |
Output is correct |
25 |
Correct |
2 ms |
1576 KB |
Output is correct |
26 |
Correct |
2 ms |
1564 KB |
Output is correct |
27 |
Correct |
2 ms |
1632 KB |
Output is correct |
28 |
Correct |
2 ms |
1708 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
25 ms |
11748 KB |
Output is correct |
2 |
Correct |
32 ms |
12064 KB |
Output is correct |
3 |
Correct |
1 ms |
1312 KB |
Output is correct |
4 |
Correct |
27 ms |
11760 KB |
Output is correct |
5 |
Correct |
30 ms |
13180 KB |
Output is correct |
6 |
Correct |
46 ms |
13044 KB |
Output is correct |
7 |
Correct |
28 ms |
12068 KB |
Output is correct |
8 |
Correct |
27 ms |
12368 KB |
Output is correct |
9 |
Correct |
35 ms |
13108 KB |
Output is correct |
10 |
Correct |
47 ms |
12964 KB |
Output is correct |
11 |
Correct |
31 ms |
13228 KB |
Output is correct |
12 |
Correct |
38 ms |
13116 KB |
Output is correct |
13 |
Correct |
32 ms |
13204 KB |
Output is correct |
14 |
Correct |
34 ms |
13128 KB |
Output is correct |
15 |
Correct |
32 ms |
13152 KB |
Output is correct |
16 |
Correct |
30 ms |
13196 KB |
Output is correct |
17 |
Correct |
27 ms |
12740 KB |
Output is correct |
18 |
Correct |
27 ms |
12888 KB |
Output is correct |
19 |
Correct |
30 ms |
12916 KB |
Output is correct |
20 |
Correct |
45 ms |
12792 KB |
Output is correct |
21 |
Correct |
32 ms |
12872 KB |
Output is correct |
22 |
Correct |
34 ms |
12988 KB |
Output is correct |
23 |
Correct |
25 ms |
11660 KB |
Output is correct |
24 |
Correct |
25 ms |
11684 KB |
Output is correct |
25 |
Correct |
36 ms |
11928 KB |
Output is correct |
26 |
Correct |
31 ms |
11948 KB |
Output is correct |
27 |
Correct |
30 ms |
12508 KB |
Output is correct |
28 |
Correct |
28 ms |
12280 KB |
Output is correct |
29 |
Correct |
30 ms |
12364 KB |
Output is correct |
30 |
Correct |
34 ms |
12312 KB |
Output is correct |
31 |
Correct |
27 ms |
11604 KB |
Output is correct |
32 |
Correct |
28 ms |
11596 KB |
Output is correct |
33 |
Correct |
28 ms |
11860 KB |
Output is correct |
34 |
Correct |
31 ms |
11940 KB |
Output is correct |
35 |
Correct |
35 ms |
12108 KB |
Output is correct |
36 |
Correct |
28 ms |
12116 KB |
Output is correct |
37 |
Correct |
33 ms |
12284 KB |
Output is correct |
38 |
Correct |
38 ms |
12156 KB |
Output is correct |
39 |
Correct |
33 ms |
12232 KB |
Output is correct |
40 |
Correct |
30 ms |
12104 KB |
Output is correct |
41 |
Correct |
34 ms |
12464 KB |
Output is correct |
42 |
Correct |
30 ms |
12592 KB |
Output is correct |
43 |
Correct |
33 ms |
12388 KB |
Output is correct |
44 |
Correct |
30 ms |
12812 KB |
Output is correct |
45 |
Correct |
31 ms |
12604 KB |
Output is correct |
46 |
Correct |
34 ms |
12608 KB |
Output is correct |
47 |
Correct |
33 ms |
12336 KB |
Output is correct |
48 |
Correct |
36 ms |
12268 KB |
Output is correct |
49 |
Correct |
37 ms |
12108 KB |
Output is correct |
50 |
Correct |
36 ms |
12096 KB |
Output is correct |
51 |
Correct |
24 ms |
11780 KB |
Output is correct |
52 |
Correct |
25 ms |
11624 KB |
Output is correct |
53 |
Correct |
30 ms |
11648 KB |
Output is correct |
54 |
Correct |
31 ms |
11692 KB |
Output is correct |
55 |
Correct |
25 ms |
11580 KB |
Output is correct |
56 |
Correct |
27 ms |
11556 KB |
Output is correct |
57 |
Correct |
27 ms |
11840 KB |
Output is correct |
58 |
Correct |
27 ms |
11920 KB |
Output is correct |
59 |
Correct |
32 ms |
12156 KB |
Output is correct |
60 |
Correct |
28 ms |
11936 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
11576 KB |
Output is correct |
2 |
Incorrect |
24 ms |
11836 KB |
Wrong Answer [5] |
3 |
Halted |
0 ms |
0 KB |
- |