Submission #778523

# Submission time Handle Problem Language Result Execution time Memory
778523 2023-07-10T11:40:30 Z bachhoangxuan Stray Cat (JOI20_stray) C++17
100 / 100
46 ms 16460 KB
#include "Anthony.h"
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
namespace {
    int c[]={0,1,0,0,1,1};

}  // namespace

vector<int> Mark(int N, int M, int A, int B,
                      std::vector<int> U, std::vector<int> V) {
    vector<int> X(M),dep(N,-1);
    vector<vector<pii>> edge(N);
    for(int i=0;i<M;i++) edge[U[i]].push_back({V[i],i}),edge[V[i]].push_back({U[i],i});
    queue<pii> q;q.push({0,0});dep[0]=0;
    while(!q.empty()){
        auto [u,d]=q.front();q.pop();
        for(auto [v,id]:edge[u]){
            if(B){
                if(dep[v]!=-1) continue;
                int nd=((int)edge[v].size()==2?(d+1)%6:(c[d]^1));
                q.push({v,dep[v]=nd});X[id]=c[d];
            }
            else if(dep[v]==-1) dep[v]=d+1,q.push({v,dep[v]});
        }
    }
    if(!B) for(int i=0;i<M;i++) X[i]=min(dep[U[i]],dep[V[i]])%3;
    return X;
}
#include "Catherine.h"
#include <bits/stdc++.h>
using namespace std;

namespace {
    int A,B,p=-1;
    int up=0,st=0,num=0;
    int f[81];
}  // namespace

void Init(int A, int B) {
    ::A = A;
    ::B = B;
    for(int i=0;i<81;i++) f[i]=-2;
    f[39]=-1;f[43]=0;f[32]=-1;f[13]=1;
    f[16]=-1;f[31]=0;f[67]=-1;f[64]=1;

}

int Move(std::vector<int> y) {
    auto g = [&](int val){return p=(val==-1?p:val),val;};
    if(A==2){
        int d=y[0]+y[1]+(st!=0);st++;
        if(up) return g(d>=3?(p^1):y[1]);
        if(d==1) return up=true,g(st!=1?-1:y[1]);
        if(d>2) return up=true,g(y[0]==0 || y[1]==0?-1:(y[1]+(p==1)>y[0]+(p==0)?0:1));
        num=num*3+y[1]+(p==1);
        if(st<=3) return g(!y[0]);
        else return up=true,g(f[num]);
    }
    else for(int i=0;i<3;i++) if(y[i] && !y[(i+2)%3]) return i;
    return -2;
}
# Verdict Execution time Memory Grader output
1 Correct 30 ms 15308 KB Output is correct
2 Correct 1 ms 520 KB Output is correct
3 Correct 26 ms 14860 KB Output is correct
4 Correct 39 ms 16460 KB Output is correct
5 Correct 38 ms 16452 KB Output is correct
6 Correct 27 ms 15088 KB Output is correct
7 Correct 28 ms 15284 KB Output is correct
8 Correct 33 ms 16076 KB Output is correct
9 Correct 44 ms 15696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 15308 KB Output is correct
2 Correct 1 ms 520 KB Output is correct
3 Correct 26 ms 14860 KB Output is correct
4 Correct 39 ms 16460 KB Output is correct
5 Correct 38 ms 16452 KB Output is correct
6 Correct 27 ms 15088 KB Output is correct
7 Correct 28 ms 15284 KB Output is correct
8 Correct 33 ms 16076 KB Output is correct
9 Correct 44 ms 15696 KB Output is correct
10 Correct 26 ms 13276 KB Output is correct
11 Correct 31 ms 13268 KB Output is correct
12 Correct 28 ms 13352 KB Output is correct
13 Correct 25 ms 13344 KB Output is correct
14 Correct 27 ms 13332 KB Output is correct
15 Correct 31 ms 13844 KB Output is correct
16 Correct 33 ms 16068 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 13056 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Correct 23 ms 12676 KB Output is correct
4 Correct 33 ms 14468 KB Output is correct
5 Correct 34 ms 14376 KB Output is correct
6 Correct 33 ms 13064 KB Output is correct
7 Correct 33 ms 13072 KB Output is correct
8 Correct 31 ms 13752 KB Output is correct
9 Correct 33 ms 13648 KB Output is correct
10 Correct 28 ms 13496 KB Output is correct
11 Correct 30 ms 13264 KB Output is correct
12 Correct 32 ms 13484 KB Output is correct
13 Correct 28 ms 13456 KB Output is correct
14 Correct 31 ms 13796 KB Output is correct
15 Correct 39 ms 13864 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 13056 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Correct 23 ms 12676 KB Output is correct
4 Correct 33 ms 14468 KB Output is correct
5 Correct 34 ms 14376 KB Output is correct
6 Correct 33 ms 13064 KB Output is correct
7 Correct 33 ms 13072 KB Output is correct
8 Correct 31 ms 13752 KB Output is correct
9 Correct 33 ms 13648 KB Output is correct
10 Correct 28 ms 13496 KB Output is correct
11 Correct 30 ms 13264 KB Output is correct
12 Correct 32 ms 13484 KB Output is correct
13 Correct 28 ms 13456 KB Output is correct
14 Correct 31 ms 13796 KB Output is correct
15 Correct 39 ms 13864 KB Output is correct
16 Correct 26 ms 11596 KB Output is correct
17 Correct 26 ms 11552 KB Output is correct
18 Correct 24 ms 11468 KB Output is correct
19 Correct 25 ms 11464 KB Output is correct
20 Correct 27 ms 12220 KB Output is correct
21 Correct 26 ms 11628 KB Output is correct
22 Correct 30 ms 13804 KB Output is correct
23 Correct 26 ms 11512 KB Output is correct
24 Correct 30 ms 11568 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 912 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Correct 2 ms 900 KB Output is correct
4 Correct 2 ms 900 KB Output is correct
5 Correct 2 ms 900 KB Output is correct
6 Correct 2 ms 900 KB Output is correct
7 Correct 2 ms 900 KB Output is correct
8 Correct 2 ms 900 KB Output is correct
9 Correct 2 ms 908 KB Output is correct
10 Correct 2 ms 900 KB Output is correct
11 Correct 2 ms 868 KB Output is correct
12 Correct 2 ms 908 KB Output is correct
13 Correct 2 ms 908 KB Output is correct
14 Correct 2 ms 908 KB Output is correct
15 Correct 2 ms 908 KB Output is correct
16 Correct 2 ms 900 KB Output is correct
17 Correct 2 ms 900 KB Output is correct
18 Correct 2 ms 900 KB Output is correct
19 Correct 2 ms 908 KB Output is correct
20 Correct 2 ms 900 KB Output is correct
21 Correct 2 ms 876 KB Output is correct
22 Correct 2 ms 868 KB Output is correct
23 Correct 2 ms 904 KB Output is correct
24 Correct 2 ms 860 KB Output is correct
25 Correct 2 ms 908 KB Output is correct
26 Correct 2 ms 908 KB Output is correct
27 Correct 2 ms 908 KB Output is correct
28 Correct 2 ms 864 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 11132 KB Output is correct
2 Correct 27 ms 11676 KB Output is correct
3 Correct 1 ms 608 KB Output is correct
4 Correct 20 ms 11160 KB Output is correct
5 Correct 33 ms 12272 KB Output is correct
6 Correct 37 ms 12368 KB Output is correct
7 Correct 26 ms 11436 KB Output is correct
8 Correct 26 ms 11428 KB Output is correct
9 Correct 31 ms 12416 KB Output is correct
10 Correct 30 ms 12364 KB Output is correct
11 Correct 31 ms 12356 KB Output is correct
12 Correct 30 ms 12360 KB Output is correct
13 Correct 30 ms 12332 KB Output is correct
14 Correct 30 ms 12420 KB Output is correct
15 Correct 30 ms 12376 KB Output is correct
16 Correct 30 ms 12344 KB Output is correct
17 Correct 28 ms 12132 KB Output is correct
18 Correct 32 ms 12072 KB Output is correct
19 Correct 27 ms 12100 KB Output is correct
20 Correct 27 ms 12124 KB Output is correct
21 Correct 32 ms 12160 KB Output is correct
22 Correct 28 ms 12104 KB Output is correct
23 Correct 26 ms 11364 KB Output is correct
24 Correct 27 ms 11404 KB Output is correct
25 Correct 26 ms 11420 KB Output is correct
26 Correct 25 ms 11476 KB Output is correct
27 Correct 32 ms 11776 KB Output is correct
28 Correct 42 ms 11844 KB Output is correct
29 Correct 36 ms 11760 KB Output is correct
30 Correct 34 ms 11916 KB Output is correct
31 Correct 25 ms 11412 KB Output is correct
32 Correct 28 ms 11316 KB Output is correct
33 Correct 28 ms 11536 KB Output is correct
34 Correct 27 ms 11436 KB Output is correct
35 Correct 31 ms 11792 KB Output is correct
36 Correct 27 ms 11744 KB Output is correct
37 Correct 30 ms 11828 KB Output is correct
38 Correct 39 ms 11816 KB Output is correct
39 Correct 33 ms 11792 KB Output is correct
40 Correct 30 ms 11856 KB Output is correct
41 Correct 28 ms 12000 KB Output is correct
42 Correct 27 ms 12104 KB Output is correct
43 Correct 40 ms 11932 KB Output is correct
44 Correct 30 ms 11996 KB Output is correct
45 Correct 38 ms 12096 KB Output is correct
46 Correct 34 ms 12056 KB Output is correct
47 Correct 27 ms 11576 KB Output is correct
48 Correct 27 ms 11700 KB Output is correct
49 Correct 27 ms 11528 KB Output is correct
50 Correct 32 ms 11772 KB Output is correct
51 Correct 28 ms 11560 KB Output is correct
52 Correct 26 ms 11584 KB Output is correct
53 Correct 28 ms 11560 KB Output is correct
54 Correct 28 ms 11544 KB Output is correct
55 Correct 30 ms 11472 KB Output is correct
56 Correct 26 ms 11632 KB Output is correct
57 Correct 36 ms 11436 KB Output is correct
58 Correct 28 ms 11380 KB Output is correct
59 Correct 27 ms 11540 KB Output is correct
60 Correct 26 ms 11380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 11328 KB Output is correct
2 Correct 28 ms 11552 KB Output is correct
3 Correct 2 ms 508 KB Output is correct
4 Correct 20 ms 11132 KB Output is correct
5 Correct 31 ms 12288 KB Output is correct
6 Correct 31 ms 12340 KB Output is correct
7 Correct 27 ms 11428 KB Output is correct
8 Correct 26 ms 11544 KB Output is correct
9 Correct 30 ms 12356 KB Output is correct
10 Correct 37 ms 12340 KB Output is correct
11 Correct 39 ms 12344 KB Output is correct
12 Correct 33 ms 12508 KB Output is correct
13 Correct 34 ms 12296 KB Output is correct
14 Correct 31 ms 12352 KB Output is correct
15 Correct 31 ms 12352 KB Output is correct
16 Correct 46 ms 12284 KB Output is correct
17 Correct 31 ms 12040 KB Output is correct
18 Correct 30 ms 12088 KB Output is correct
19 Correct 33 ms 12040 KB Output is correct
20 Correct 32 ms 12024 KB Output is correct
21 Correct 34 ms 12012 KB Output is correct
22 Correct 27 ms 12084 KB Output is correct
23 Correct 26 ms 11316 KB Output is correct
24 Correct 31 ms 11224 KB Output is correct
25 Correct 26 ms 11432 KB Output is correct
26 Correct 25 ms 11460 KB Output is correct
27 Correct 28 ms 11804 KB Output is correct
28 Correct 28 ms 11808 KB Output is correct
29 Correct 34 ms 11896 KB Output is correct
30 Correct 27 ms 11804 KB Output is correct
31 Correct 46 ms 11296 KB Output is correct
32 Correct 27 ms 11384 KB Output is correct
33 Correct 25 ms 11448 KB Output is correct
34 Correct 27 ms 11404 KB Output is correct
35 Correct 41 ms 11784 KB Output is correct
36 Correct 28 ms 11860 KB Output is correct
37 Correct 45 ms 11708 KB Output is correct
38 Correct 27 ms 11776 KB Output is correct
39 Correct 26 ms 11824 KB Output is correct
40 Correct 28 ms 11800 KB Output is correct
41 Correct 35 ms 12084 KB Output is correct
42 Correct 28 ms 12048 KB Output is correct
43 Correct 31 ms 12092 KB Output is correct
44 Correct 28 ms 12068 KB Output is correct
45 Correct 28 ms 12104 KB Output is correct
46 Correct 30 ms 12060 KB Output is correct
47 Correct 31 ms 11700 KB Output is correct
48 Correct 28 ms 11664 KB Output is correct
49 Correct 27 ms 11596 KB Output is correct
50 Correct 26 ms 11716 KB Output is correct
51 Correct 25 ms 11536 KB Output is correct
52 Correct 24 ms 11568 KB Output is correct
53 Correct 26 ms 11564 KB Output is correct
54 Correct 27 ms 11564 KB Output is correct
55 Correct 28 ms 11572 KB Output is correct
56 Correct 24 ms 11604 KB Output is correct
57 Correct 26 ms 11480 KB Output is correct
58 Correct 25 ms 11504 KB Output is correct
59 Correct 32 ms 11528 KB Output is correct
60 Correct 27 ms 11548 KB Output is correct