# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
939330 |
2024-03-06T09:20:39 Z |
Pring |
Stray Cat (JOI20_stray) |
C++17 |
|
42 ms |
17188 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));
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
34 ms |
15944 KB |
Output is correct |
2 |
Correct |
1 ms |
1308 KB |
Output is correct |
3 |
Correct |
25 ms |
15192 KB |
Output is correct |
4 |
Correct |
37 ms |
16948 KB |
Output is correct |
5 |
Correct |
41 ms |
17188 KB |
Output is correct |
6 |
Correct |
32 ms |
15572 KB |
Output is correct |
7 |
Correct |
31 ms |
15752 KB |
Output is correct |
8 |
Correct |
39 ms |
16344 KB |
Output is correct |
9 |
Correct |
37 ms |
16484 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
34 ms |
15944 KB |
Output is correct |
2 |
Correct |
1 ms |
1308 KB |
Output is correct |
3 |
Correct |
25 ms |
15192 KB |
Output is correct |
4 |
Correct |
37 ms |
16948 KB |
Output is correct |
5 |
Correct |
41 ms |
17188 KB |
Output is correct |
6 |
Correct |
32 ms |
15572 KB |
Output is correct |
7 |
Correct |
31 ms |
15752 KB |
Output is correct |
8 |
Correct |
39 ms |
16344 KB |
Output is correct |
9 |
Correct |
37 ms |
16484 KB |
Output is correct |
10 |
Correct |
35 ms |
13688 KB |
Output is correct |
11 |
Correct |
28 ms |
13664 KB |
Output is correct |
12 |
Correct |
26 ms |
13684 KB |
Output is correct |
13 |
Correct |
33 ms |
13616 KB |
Output is correct |
14 |
Correct |
30 ms |
13900 KB |
Output is correct |
15 |
Correct |
30 ms |
14364 KB |
Output is correct |
16 |
Correct |
37 ms |
16560 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
13672 KB |
Output is correct |
2 |
Correct |
1 ms |
1292 KB |
Output is correct |
3 |
Correct |
25 ms |
12924 KB |
Output is correct |
4 |
Correct |
38 ms |
14728 KB |
Output is correct |
5 |
Correct |
34 ms |
14940 KB |
Output is correct |
6 |
Correct |
29 ms |
13416 KB |
Output is correct |
7 |
Correct |
28 ms |
13548 KB |
Output is correct |
8 |
Correct |
34 ms |
14136 KB |
Output is correct |
9 |
Correct |
42 ms |
14040 KB |
Output is correct |
10 |
Correct |
37 ms |
13844 KB |
Output is correct |
11 |
Correct |
28 ms |
13800 KB |
Output is correct |
12 |
Correct |
28 ms |
13832 KB |
Output is correct |
13 |
Correct |
34 ms |
13964 KB |
Output is correct |
14 |
Correct |
32 ms |
14180 KB |
Output is correct |
15 |
Correct |
28 ms |
14188 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
13672 KB |
Output is correct |
2 |
Correct |
1 ms |
1292 KB |
Output is correct |
3 |
Correct |
25 ms |
12924 KB |
Output is correct |
4 |
Correct |
38 ms |
14728 KB |
Output is correct |
5 |
Correct |
34 ms |
14940 KB |
Output is correct |
6 |
Correct |
29 ms |
13416 KB |
Output is correct |
7 |
Correct |
28 ms |
13548 KB |
Output is correct |
8 |
Correct |
34 ms |
14136 KB |
Output is correct |
9 |
Correct |
42 ms |
14040 KB |
Output is correct |
10 |
Correct |
37 ms |
13844 KB |
Output is correct |
11 |
Correct |
28 ms |
13800 KB |
Output is correct |
12 |
Correct |
28 ms |
13832 KB |
Output is correct |
13 |
Correct |
34 ms |
13964 KB |
Output is correct |
14 |
Correct |
32 ms |
14180 KB |
Output is correct |
15 |
Correct |
28 ms |
14188 KB |
Output is correct |
16 |
Correct |
25 ms |
11936 KB |
Output is correct |
17 |
Correct |
25 ms |
11868 KB |
Output is correct |
18 |
Correct |
25 ms |
11620 KB |
Output is correct |
19 |
Correct |
25 ms |
11580 KB |
Output is correct |
20 |
Correct |
31 ms |
12464 KB |
Output is correct |
21 |
Correct |
26 ms |
12004 KB |
Output is correct |
22 |
Correct |
31 ms |
14452 KB |
Output is correct |
23 |
Correct |
27 ms |
11804 KB |
Output is correct |
24 |
Correct |
24 ms |
11828 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1552 KB |
Output is correct |
2 |
Correct |
1 ms |
1292 KB |
Output is correct |
3 |
Correct |
2 ms |
1564 KB |
Output is correct |
4 |
Correct |
1 ms |
1560 KB |
Output is correct |
5 |
Correct |
2 ms |
1556 KB |
Output is correct |
6 |
Correct |
2 ms |
1560 KB |
Output is correct |
7 |
Correct |
2 ms |
1560 KB |
Output is correct |
8 |
Correct |
2 ms |
1568 KB |
Output is correct |
9 |
Correct |
1 ms |
1560 KB |
Output is correct |
10 |
Correct |
2 ms |
1564 KB |
Output is correct |
11 |
Correct |
2 ms |
1568 KB |
Output is correct |
12 |
Correct |
2 ms |
1568 KB |
Output is correct |
13 |
Correct |
2 ms |
1600 KB |
Output is correct |
14 |
Correct |
2 ms |
1568 KB |
Output is correct |
15 |
Correct |
2 ms |
1568 KB |
Output is correct |
16 |
Correct |
2 ms |
1736 KB |
Output is correct |
17 |
Correct |
2 ms |
1560 KB |
Output is correct |
18 |
Correct |
1 ms |
1560 KB |
Output is correct |
19 |
Correct |
1 ms |
1812 KB |
Output is correct |
20 |
Correct |
1 ms |
1568 KB |
Output is correct |
21 |
Correct |
2 ms |
1556 KB |
Output is correct |
22 |
Correct |
2 ms |
1568 KB |
Output is correct |
23 |
Correct |
2 ms |
1812 KB |
Output is correct |
24 |
Correct |
2 ms |
1564 KB |
Output is correct |
25 |
Correct |
2 ms |
1568 KB |
Output is correct |
26 |
Correct |
1 ms |
1564 KB |
Output is correct |
27 |
Correct |
2 ms |
1564 KB |
Output is correct |
28 |
Correct |
2 ms |
1560 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
25 ms |
11376 KB |
Output is correct |
2 |
Correct |
33 ms |
11732 KB |
Output is correct |
3 |
Correct |
1 ms |
1292 KB |
Output is correct |
4 |
Correct |
20 ms |
11356 KB |
Output is correct |
5 |
Correct |
31 ms |
12656 KB |
Output is correct |
6 |
Correct |
28 ms |
12596 KB |
Output is correct |
7 |
Correct |
25 ms |
11644 KB |
Output is correct |
8 |
Correct |
25 ms |
11800 KB |
Output is correct |
9 |
Correct |
33 ms |
12592 KB |
Output is correct |
10 |
Correct |
31 ms |
12668 KB |
Output is correct |
11 |
Correct |
28 ms |
12664 KB |
Output is correct |
12 |
Correct |
32 ms |
12652 KB |
Output is correct |
13 |
Correct |
28 ms |
12564 KB |
Output is correct |
14 |
Correct |
30 ms |
12656 KB |
Output is correct |
15 |
Correct |
36 ms |
12580 KB |
Output is correct |
16 |
Correct |
28 ms |
12668 KB |
Output is correct |
17 |
Correct |
28 ms |
12396 KB |
Output is correct |
18 |
Correct |
27 ms |
12412 KB |
Output is correct |
19 |
Correct |
27 ms |
12408 KB |
Output is correct |
20 |
Correct |
30 ms |
12204 KB |
Output is correct |
21 |
Correct |
27 ms |
12200 KB |
Output is correct |
22 |
Correct |
27 ms |
12364 KB |
Output is correct |
23 |
Correct |
24 ms |
11132 KB |
Output is correct |
24 |
Correct |
24 ms |
11140 KB |
Output is correct |
25 |
Correct |
29 ms |
11380 KB |
Output is correct |
26 |
Correct |
25 ms |
11592 KB |
Output is correct |
27 |
Correct |
26 ms |
11780 KB |
Output is correct |
28 |
Correct |
26 ms |
11896 KB |
Output is correct |
29 |
Correct |
28 ms |
12144 KB |
Output is correct |
30 |
Correct |
27 ms |
11872 KB |
Output is correct |
31 |
Correct |
26 ms |
11124 KB |
Output is correct |
32 |
Correct |
24 ms |
11092 KB |
Output is correct |
33 |
Correct |
25 ms |
12148 KB |
Output is correct |
34 |
Correct |
25 ms |
11568 KB |
Output is correct |
35 |
Correct |
27 ms |
11636 KB |
Output is correct |
36 |
Correct |
26 ms |
11636 KB |
Output is correct |
37 |
Correct |
26 ms |
11636 KB |
Output is correct |
38 |
Correct |
30 ms |
12040 KB |
Output is correct |
39 |
Correct |
34 ms |
11940 KB |
Output is correct |
40 |
Correct |
26 ms |
11644 KB |
Output is correct |
41 |
Correct |
27 ms |
12144 KB |
Output is correct |
42 |
Correct |
27 ms |
12060 KB |
Output is correct |
43 |
Correct |
27 ms |
11976 KB |
Output is correct |
44 |
Correct |
28 ms |
12116 KB |
Output is correct |
45 |
Correct |
27 ms |
12136 KB |
Output is correct |
46 |
Correct |
28 ms |
12120 KB |
Output is correct |
47 |
Correct |
26 ms |
11660 KB |
Output is correct |
48 |
Correct |
26 ms |
11692 KB |
Output is correct |
49 |
Correct |
26 ms |
11648 KB |
Output is correct |
50 |
Correct |
26 ms |
11616 KB |
Output is correct |
51 |
Correct |
27 ms |
11096 KB |
Output is correct |
52 |
Correct |
25 ms |
11116 KB |
Output is correct |
53 |
Correct |
24 ms |
11388 KB |
Output is correct |
54 |
Correct |
24 ms |
11116 KB |
Output is correct |
55 |
Correct |
25 ms |
11088 KB |
Output is correct |
56 |
Correct |
24 ms |
11384 KB |
Output is correct |
57 |
Correct |
25 ms |
11640 KB |
Output is correct |
58 |
Correct |
24 ms |
11384 KB |
Output is correct |
59 |
Correct |
25 ms |
11528 KB |
Output is correct |
60 |
Correct |
24 ms |
11448 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
11388 KB |
Output is correct |
2 |
Incorrect |
23 ms |
11428 KB |
Wrong Answer [5] |
3 |
Halted |
0 ms |
0 KB |
- |