Submission #764039

# Submission time Handle Problem Language Result Execution time Memory
764039 2023-06-23T06:05:59 Z boyliguanhan Stray Cat (JOI20_stray) C++17
100 / 100
41 ms 16604 KB
#include "Anthony.h"
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
vector<int> X, paint{0, 1, 0, 0, 1, 1};
vector<pair<int, int>> adj[20000];
int vis[20000];
void m1(int n = 0, int pi = -1, int depth = 0) {
    if (pi+1) X[pi] = paint[depth];
    for (auto i : adj[n])
        if (i.S != pi) {
            if (adj[n].size() == 2) 
                m1(i.F, i.S, (depth + 1) % 6);
            else
                m1(i.F, i.S, 1 ^ paint[depth]);
        }
}
void m2() {
    queue<int> q;
    q.push(0);
    vis[0] = 1;
    while (q.size()) {
        int n = q.front();
        q.pop();
        for (auto i : adj[n])
            if (!vis[i.F]) {
                X[i.S] = (vis[n] - 1) % 3;
                vis[i.F] = vis[n] + 1;
                q.push(i.F); 
            } else
                X[i.S] = (vis[i.F] - 1) % 3;
    }
}
vector<int> Mark(int N, int M, int A, int B, vector<int> U, vector<int> V) {
    for(int i = 0; i < M; i++) {
        adj[U[i]].push_back({V[i], i});
        adj[V[i]].push_back({U[i], i});
    }
    X.resize(M);
    if (B) m1();
    else m2();
    return X;
}
#include "Catherine.h"
#include <bits/stdc++.h>
using namespace std;
int a, b, last;
bool up;
vector<int> seen;
vector<vector<int>> poss = {{1, 1, 0, 0, 1},{1, 0, 0, 1, 0},{0, 0, 1, 0, 1},{0, 1, 0, 1, 1},{1, 0, 1, 1, 0},{0, 1, 1, 0, 0},};
int move_tree(vector<int> y) {
    vector<int> y2 = y;
    if (last+1) y2[last]++;
    int cnt = 0;
    for(auto i: y2)
        cnt+=i;
    if (cnt != 2)
        up = 1;
    if (up) {
        if (cnt == 1){
            if (last==-1)
                for(int i = 0; i < a; i++)
                    if (y[i])
                        return last = i;
            return -1;
        } else if (cnt == 2) {
            for(int i = 0; i < a; i++)
                if (y[i])
                    return last = i;
        } else {
            for(int i = 0; i < a; i++)
                if (y2[i] == 1) {
                    if (!y[i])
                        return -1;
                    return last = i;
                }
        }
    } else{
        if (last+1){
            for(int i = 0; i < a; i++)
                if (y[i]) {
                    seen.push_back(i);
                    if (seen.size() < 5)
                        return last = i;
                    else {
                        up = 1;
                        for (vector<int> v : poss)
                            if (v == seen)
                                return last = i;
                        return -1;
                    }
                }
        }else{
            for(int i = 0; i < a; i++) 
                if (y[i]) {
                    seen.push_back(i);
                    y[i]--;
                    for(int j = 0; j < a; j++)
                        if (y[j]) {
                            seen.push_back(j);
                            return last = j;
                        }
                }
        }
    }
}
int move_graph(vector<int> y) {
    if (last+1) y[last]++;
    for(int i = 0; i < 3; i++)
        if (y[i] && y[(i + 1) % 3])
            return last = i;
    for(int i = 0; i < 3; i++)
        if (y[i])
            return last = i;
}   
void Init(int A, int B) {
    a = A;
    b = B;
    up = false;
    last = -1;
}
int Move(vector<int> y) {
    if (b)
        return move_tree(y);
    return move_graph(y);
}

Compilation message

Catherine.cpp: In function 'int move_tree(std::vector<int>)':
Catherine.cpp:9:22: warning: control reaches end of non-void function [-Wreturn-type]
    9 |     vector<int> y2 = y;
      |                      ^
Catherine.cpp: In function 'int move_graph(std::vector<int>)':
Catherine.cpp:72:1: warning: control reaches end of non-void function [-Wreturn-type]
   72 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 30 ms 15480 KB Output is correct
2 Correct 1 ms 1036 KB Output is correct
3 Correct 25 ms 14788 KB Output is correct
4 Correct 40 ms 16560 KB Output is correct
5 Correct 34 ms 16604 KB Output is correct
6 Correct 27 ms 15332 KB Output is correct
7 Correct 28 ms 15308 KB Output is correct
8 Correct 33 ms 16036 KB Output is correct
9 Correct 33 ms 15968 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 15480 KB Output is correct
2 Correct 1 ms 1036 KB Output is correct
3 Correct 25 ms 14788 KB Output is correct
4 Correct 40 ms 16560 KB Output is correct
5 Correct 34 ms 16604 KB Output is correct
6 Correct 27 ms 15332 KB Output is correct
7 Correct 28 ms 15308 KB Output is correct
8 Correct 33 ms 16036 KB Output is correct
9 Correct 33 ms 15968 KB Output is correct
10 Correct 25 ms 13368 KB Output is correct
11 Correct 25 ms 13356 KB Output is correct
12 Correct 25 ms 13360 KB Output is correct
13 Correct 25 ms 13380 KB Output is correct
14 Correct 28 ms 13536 KB Output is correct
15 Correct 28 ms 14000 KB Output is correct
16 Correct 31 ms 16100 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 13076 KB Output is correct
2 Correct 1 ms 1024 KB Output is correct
3 Correct 22 ms 12788 KB Output is correct
4 Correct 34 ms 14332 KB Output is correct
5 Correct 35 ms 14280 KB Output is correct
6 Correct 26 ms 13104 KB Output is correct
7 Correct 26 ms 13120 KB Output is correct
8 Correct 34 ms 13672 KB Output is correct
9 Correct 31 ms 13672 KB Output is correct
10 Correct 30 ms 13500 KB Output is correct
11 Correct 28 ms 13332 KB Output is correct
12 Correct 30 ms 13428 KB Output is correct
13 Correct 28 ms 13484 KB Output is correct
14 Correct 30 ms 13816 KB Output is correct
15 Correct 32 ms 13664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 13076 KB Output is correct
2 Correct 1 ms 1024 KB Output is correct
3 Correct 22 ms 12788 KB Output is correct
4 Correct 34 ms 14332 KB Output is correct
5 Correct 35 ms 14280 KB Output is correct
6 Correct 26 ms 13104 KB Output is correct
7 Correct 26 ms 13120 KB Output is correct
8 Correct 34 ms 13672 KB Output is correct
9 Correct 31 ms 13672 KB Output is correct
10 Correct 30 ms 13500 KB Output is correct
11 Correct 28 ms 13332 KB Output is correct
12 Correct 30 ms 13428 KB Output is correct
13 Correct 28 ms 13484 KB Output is correct
14 Correct 30 ms 13816 KB Output is correct
15 Correct 32 ms 13664 KB Output is correct
16 Correct 23 ms 11620 KB Output is correct
17 Correct 25 ms 11560 KB Output is correct
18 Correct 25 ms 11408 KB Output is correct
19 Correct 24 ms 11492 KB Output is correct
20 Correct 26 ms 12228 KB Output is correct
21 Correct 25 ms 11836 KB Output is correct
22 Correct 28 ms 13964 KB Output is correct
23 Correct 28 ms 11620 KB Output is correct
24 Correct 26 ms 11524 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1292 KB Output is correct
2 Correct 1 ms 1088 KB Output is correct
3 Correct 2 ms 1296 KB Output is correct
4 Correct 2 ms 1292 KB Output is correct
5 Correct 2 ms 1292 KB Output is correct
6 Correct 2 ms 1352 KB Output is correct
7 Correct 2 ms 1284 KB Output is correct
8 Correct 2 ms 1296 KB Output is correct
9 Correct 2 ms 1340 KB Output is correct
10 Correct 2 ms 1288 KB Output is correct
11 Correct 2 ms 1288 KB Output is correct
12 Correct 2 ms 1352 KB Output is correct
13 Correct 2 ms 1244 KB Output is correct
14 Correct 2 ms 1288 KB Output is correct
15 Correct 2 ms 1300 KB Output is correct
16 Correct 2 ms 1296 KB Output is correct
17 Correct 2 ms 1288 KB Output is correct
18 Correct 2 ms 1288 KB Output is correct
19 Correct 2 ms 1344 KB Output is correct
20 Correct 2 ms 1548 KB Output is correct
21 Correct 2 ms 1288 KB Output is correct
22 Correct 2 ms 1288 KB Output is correct
23 Correct 2 ms 1352 KB Output is correct
24 Correct 2 ms 1284 KB Output is correct
25 Correct 2 ms 1288 KB Output is correct
26 Correct 2 ms 1296 KB Output is correct
27 Correct 2 ms 1288 KB Output is correct
28 Correct 2 ms 1344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 11204 KB Output is correct
2 Correct 30 ms 12336 KB Output is correct
3 Correct 1 ms 1028 KB Output is correct
4 Correct 22 ms 11472 KB Output is correct
5 Correct 31 ms 14012 KB Output is correct
6 Correct 31 ms 13996 KB Output is correct
7 Correct 26 ms 13080 KB Output is correct
8 Correct 27 ms 13120 KB Output is correct
9 Correct 34 ms 13848 KB Output is correct
10 Correct 37 ms 14044 KB Output is correct
11 Correct 32 ms 14028 KB Output is correct
12 Correct 34 ms 13944 KB Output is correct
13 Correct 33 ms 14080 KB Output is correct
14 Correct 41 ms 13896 KB Output is correct
15 Correct 32 ms 13888 KB Output is correct
16 Correct 32 ms 13944 KB Output is correct
17 Correct 28 ms 13680 KB Output is correct
18 Correct 30 ms 13652 KB Output is correct
19 Correct 30 ms 13656 KB Output is correct
20 Correct 28 ms 13768 KB Output is correct
21 Correct 28 ms 13740 KB Output is correct
22 Correct 30 ms 13608 KB Output is correct
23 Correct 25 ms 11728 KB Output is correct
24 Correct 25 ms 11716 KB Output is correct
25 Correct 25 ms 12096 KB Output is correct
26 Correct 25 ms 12116 KB Output is correct
27 Correct 27 ms 12748 KB Output is correct
28 Correct 35 ms 12784 KB Output is correct
29 Correct 27 ms 12716 KB Output is correct
30 Correct 28 ms 12852 KB Output is correct
31 Correct 25 ms 11700 KB Output is correct
32 Correct 25 ms 11792 KB Output is correct
33 Correct 24 ms 12076 KB Output is correct
34 Correct 27 ms 11984 KB Output is correct
35 Correct 36 ms 12716 KB Output is correct
36 Correct 28 ms 12856 KB Output is correct
37 Correct 27 ms 12748 KB Output is correct
38 Correct 27 ms 12744 KB Output is correct
39 Correct 27 ms 12756 KB Output is correct
40 Correct 27 ms 12728 KB Output is correct
41 Correct 28 ms 13472 KB Output is correct
42 Correct 30 ms 13304 KB Output is correct
43 Correct 28 ms 13296 KB Output is correct
44 Correct 30 ms 13232 KB Output is correct
45 Correct 30 ms 13300 KB Output is correct
46 Correct 30 ms 13308 KB Output is correct
47 Correct 27 ms 12616 KB Output is correct
48 Correct 27 ms 12608 KB Output is correct
49 Correct 27 ms 12420 KB Output is correct
50 Correct 27 ms 12508 KB Output is correct
51 Correct 25 ms 11960 KB Output is correct
52 Correct 25 ms 11860 KB Output is correct
53 Correct 27 ms 11980 KB Output is correct
54 Correct 25 ms 11844 KB Output is correct
55 Correct 29 ms 11800 KB Output is correct
56 Correct 26 ms 11840 KB Output is correct
57 Correct 25 ms 11672 KB Output is correct
58 Correct 25 ms 11784 KB Output is correct
59 Correct 27 ms 11840 KB Output is correct
60 Correct 25 ms 11848 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 11292 KB Output is correct
2 Correct 30 ms 12532 KB Output is correct
3 Correct 1 ms 1100 KB Output is correct
4 Correct 20 ms 11428 KB Output is correct
5 Correct 31 ms 13916 KB Output is correct
6 Correct 31 ms 14004 KB Output is correct
7 Correct 27 ms 13080 KB Output is correct
8 Correct 27 ms 13092 KB Output is correct
9 Correct 31 ms 13928 KB Output is correct
10 Correct 32 ms 13996 KB Output is correct
11 Correct 30 ms 13936 KB Output is correct
12 Correct 36 ms 14036 KB Output is correct
13 Correct 32 ms 13984 KB Output is correct
14 Correct 31 ms 14004 KB Output is correct
15 Correct 32 ms 13964 KB Output is correct
16 Correct 34 ms 13976 KB Output is correct
17 Correct 37 ms 13640 KB Output is correct
18 Correct 31 ms 13656 KB Output is correct
19 Correct 30 ms 13696 KB Output is correct
20 Correct 28 ms 13644 KB Output is correct
21 Correct 28 ms 13680 KB Output is correct
22 Correct 28 ms 13704 KB Output is correct
23 Correct 25 ms 11656 KB Output is correct
24 Correct 25 ms 11784 KB Output is correct
25 Correct 30 ms 11952 KB Output is correct
26 Correct 24 ms 12040 KB Output is correct
27 Correct 27 ms 12848 KB Output is correct
28 Correct 27 ms 12904 KB Output is correct
29 Correct 27 ms 12868 KB Output is correct
30 Correct 27 ms 12812 KB Output is correct
31 Correct 25 ms 11696 KB Output is correct
32 Correct 24 ms 11664 KB Output is correct
33 Correct 25 ms 12100 KB Output is correct
34 Correct 25 ms 12060 KB Output is correct
35 Correct 27 ms 12704 KB Output is correct
36 Correct 27 ms 12664 KB Output is correct
37 Correct 27 ms 12724 KB Output is correct
38 Correct 30 ms 12744 KB Output is correct
39 Correct 28 ms 12672 KB Output is correct
40 Correct 33 ms 12656 KB Output is correct
41 Correct 40 ms 13160 KB Output is correct
42 Correct 33 ms 13232 KB Output is correct
43 Correct 32 ms 13236 KB Output is correct
44 Correct 33 ms 13244 KB Output is correct
45 Correct 30 ms 13256 KB Output is correct
46 Correct 32 ms 13236 KB Output is correct
47 Correct 33 ms 12568 KB Output is correct
48 Correct 28 ms 12508 KB Output is correct
49 Correct 28 ms 12468 KB Output is correct
50 Correct 30 ms 12472 KB Output is correct
51 Correct 33 ms 11708 KB Output is correct
52 Correct 26 ms 11844 KB Output is correct
53 Correct 32 ms 11884 KB Output is correct
54 Correct 31 ms 11808 KB Output is correct
55 Correct 26 ms 11888 KB Output is correct
56 Correct 30 ms 11796 KB Output is correct
57 Correct 31 ms 11784 KB Output is correct
58 Correct 26 ms 11720 KB Output is correct
59 Correct 26 ms 11896 KB Output is correct
60 Correct 31 ms 11760 KB Output is correct