Submission #924246

# Submission time Handle Problem Language Result Execution time Memory
924246 2024-02-08T16:58:20 Z Tuanlinh123 Stray Cat (JOI20_stray) C++17
100 / 100
42 ms 16220 KB
#include "Anthony.h"
#include<bits/stdc++.h>
#define ll int
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ld long double
using namespace std;

vector <ll> s={0, 1, 0, 0, 1, 1};
vector <ll> Mark(ll n, ll m, ll a, ll b, vector <ll> U, vector <ll> V)
{
    vector <ll> ans(m);
    vector <vector <pll>> A(n);
    for (ll i=0; i<m; i++)
        A[U[i]].pb({V[i], i}), A[V[i]].pb({U[i], i});
    vector <ll> dep(n, 0);
    auto bfs=[&]()
    {
        queue <ll> q; q.push(0), dep[0]=1;
        while (!q.empty())
        {
            ll u=q.front(); q.pop();
            for (auto [v, id]:A[u])
            {
                if (!dep[v])
                    q.push(v), dep[v]=dep[u]+1;
                ans[id]=min(dep[u], dep[v])%3;
            }
        }
    };
    function <void(int, int)> dfs=[&](ll u, ll pa)
    {
        ll cnt=A[u].size()-(pa!=-1);
        for (auto [v, id]:A[u])
        {
            if (v==pa) continue;
            if (cnt==1 || pa==-1) 
                ans[id]=s[dep[u]], dep[v]=(dep[u]+1)%6;
            else ans[id]=s[(dep[u]+5)%6]^1, dep[v]=ans[id]^1;
            dfs(v, u);
        }
    };
    if (a>2) bfs();
    else dfs(0, -1);
    return ans;
}
#include "Catherine.h"
#include<bits/stdc++.h>
#define ll int
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ld long double
using namespace std;

string crr;
ll A, B, cnt, ok, last=-1;
void Init(ll a, ll b) {A=a, B=b;}

ll Move(vector <ll> y)
{
    if (A>2)
    {
        if (!y[0] && !y[1]) return 2;
        if (!y[2] && !y[1]) return 0;
        if (!y[0] && !y[2]) return 1;
        if (y[0] && y[1]) return 0;
        if (y[1] && y[2]) return 1;
        return 2;
    }
    if (ok)
    {
        if (!y[0]) return last=1;
        if (!y[1]) return last=0;
        return last=last^1;
    }
    cnt++; if (cnt==4) ok=1;
    if (last==-1)
    {
        ll s=y[0]+y[1];
        if (s>=3 && y[0]>1) {ok=1; return last=1;}
        if (s>=3 && y[1]>1) {ok=1; return last=0;}
        if (s<=1 && !y[0]) {ok=1; return last=1;}
        if (s<=1 && !y[1]) {ok=1; return last=0;}
        if (y[0]>1) {crr="00"; return last=0;}
        if (y[1]>1) {crr="11"; return last=1;}
        crr="01"; return last=1;
    }
    if (!y[0] && !y[1]) {ok=1; return -1;}
    if (!y[last] && y[last^1]>1) {ok=1; return -1;}
    if (y[0] && y[1]) {ok=1; return last=last^1;}
    if (cnt<4)
    {
        if (y[0]) {crr.pb('0'); return last=0;}
        if (y[1]) {crr.pb('1'); return last=1;}
    }
    crr.pb(y[0]?'0':'1');
    if (crr=="01001") return -1;
    if (crr=="10011") return -1;
    if (crr=="00110") return -1;
    if (crr=="01101") return -1;
    if (crr=="11010") return -1;
    if (crr=="10100") return -1;
    if (y[0]) return last=0;
    return last=1;
}
# Verdict Execution time Memory Grader output
1 Correct 27 ms 15268 KB Output is correct
2 Correct 0 ms 792 KB Output is correct
3 Correct 23 ms 14704 KB Output is correct
4 Correct 34 ms 16088 KB Output is correct
5 Correct 33 ms 16220 KB Output is correct
6 Correct 26 ms 15012 KB Output is correct
7 Correct 28 ms 14976 KB Output is correct
8 Correct 31 ms 15744 KB Output is correct
9 Correct 30 ms 15792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 15268 KB Output is correct
2 Correct 0 ms 792 KB Output is correct
3 Correct 23 ms 14704 KB Output is correct
4 Correct 34 ms 16088 KB Output is correct
5 Correct 33 ms 16220 KB Output is correct
6 Correct 26 ms 15012 KB Output is correct
7 Correct 28 ms 14976 KB Output is correct
8 Correct 31 ms 15744 KB Output is correct
9 Correct 30 ms 15792 KB Output is correct
10 Correct 25 ms 13164 KB Output is correct
11 Correct 25 ms 13176 KB Output is correct
12 Correct 26 ms 13080 KB Output is correct
13 Correct 25 ms 13180 KB Output is correct
14 Correct 26 ms 13452 KB Output is correct
15 Correct 28 ms 13692 KB Output is correct
16 Correct 30 ms 15884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 12712 KB Output is correct
2 Correct 0 ms 788 KB Output is correct
3 Correct 22 ms 12692 KB Output is correct
4 Correct 32 ms 14204 KB Output is correct
5 Correct 31 ms 14456 KB Output is correct
6 Correct 26 ms 12708 KB Output is correct
7 Correct 26 ms 12724 KB Output is correct
8 Correct 28 ms 13484 KB Output is correct
9 Correct 28 ms 13452 KB Output is correct
10 Correct 26 ms 13220 KB Output is correct
11 Correct 27 ms 13232 KB Output is correct
12 Correct 27 ms 13224 KB Output is correct
13 Correct 27 ms 13184 KB Output is correct
14 Correct 28 ms 13404 KB Output is correct
15 Correct 28 ms 13476 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 12712 KB Output is correct
2 Correct 0 ms 788 KB Output is correct
3 Correct 22 ms 12692 KB Output is correct
4 Correct 32 ms 14204 KB Output is correct
5 Correct 31 ms 14456 KB Output is correct
6 Correct 26 ms 12708 KB Output is correct
7 Correct 26 ms 12724 KB Output is correct
8 Correct 28 ms 13484 KB Output is correct
9 Correct 28 ms 13452 KB Output is correct
10 Correct 26 ms 13220 KB Output is correct
11 Correct 27 ms 13232 KB Output is correct
12 Correct 27 ms 13224 KB Output is correct
13 Correct 27 ms 13184 KB Output is correct
14 Correct 28 ms 13404 KB Output is correct
15 Correct 28 ms 13476 KB Output is correct
16 Correct 23 ms 11244 KB Output is correct
17 Correct 23 ms 11244 KB Output is correct
18 Correct 25 ms 11476 KB Output is correct
19 Correct 24 ms 11596 KB Output is correct
20 Correct 26 ms 11912 KB Output is correct
21 Correct 25 ms 11644 KB Output is correct
22 Correct 31 ms 13584 KB Output is correct
23 Correct 25 ms 11884 KB Output is correct
24 Correct 25 ms 11388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1044 KB Output is correct
2 Correct 0 ms 792 KB Output is correct
3 Correct 1 ms 1040 KB Output is correct
4 Correct 2 ms 1072 KB Output is correct
5 Correct 2 ms 1036 KB Output is correct
6 Correct 1 ms 1044 KB Output is correct
7 Correct 1 ms 1036 KB Output is correct
8 Correct 2 ms 1044 KB Output is correct
9 Correct 2 ms 1048 KB Output is correct
10 Correct 1 ms 1056 KB Output is correct
11 Correct 2 ms 1044 KB Output is correct
12 Correct 2 ms 1052 KB Output is correct
13 Correct 0 ms 1044 KB Output is correct
14 Correct 1 ms 1040 KB Output is correct
15 Correct 1 ms 1036 KB Output is correct
16 Correct 1 ms 1044 KB Output is correct
17 Correct 1 ms 1044 KB Output is correct
18 Correct 1 ms 1304 KB Output is correct
19 Correct 2 ms 1048 KB Output is correct
20 Correct 1 ms 1052 KB Output is correct
21 Correct 1 ms 1044 KB Output is correct
22 Correct 0 ms 1044 KB Output is correct
23 Correct 1 ms 1044 KB Output is correct
24 Correct 1 ms 1044 KB Output is correct
25 Correct 2 ms 1052 KB Output is correct
26 Correct 1 ms 1044 KB Output is correct
27 Correct 2 ms 1052 KB Output is correct
28 Correct 1 ms 1052 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 11132 KB Output is correct
2 Correct 27 ms 12368 KB Output is correct
3 Correct 0 ms 792 KB Output is correct
4 Correct 20 ms 10880 KB Output is correct
5 Correct 42 ms 14192 KB Output is correct
6 Correct 30 ms 13988 KB Output is correct
7 Correct 27 ms 12972 KB Output is correct
8 Correct 26 ms 12976 KB Output is correct
9 Correct 30 ms 13992 KB Output is correct
10 Correct 37 ms 13996 KB Output is correct
11 Correct 30 ms 13816 KB Output is correct
12 Correct 30 ms 14000 KB Output is correct
13 Correct 30 ms 13956 KB Output is correct
14 Correct 30 ms 13976 KB Output is correct
15 Correct 30 ms 14000 KB Output is correct
16 Correct 30 ms 14000 KB Output is correct
17 Correct 30 ms 13712 KB Output is correct
18 Correct 37 ms 13696 KB Output is correct
19 Correct 28 ms 13748 KB Output is correct
20 Correct 27 ms 13548 KB Output is correct
21 Correct 28 ms 13752 KB Output is correct
22 Correct 28 ms 13640 KB Output is correct
23 Correct 25 ms 11140 KB Output is correct
24 Correct 24 ms 11140 KB Output is correct
25 Correct 24 ms 11664 KB Output is correct
26 Correct 24 ms 12040 KB Output is correct
27 Correct 27 ms 12672 KB Output is correct
28 Correct 27 ms 12672 KB Output is correct
29 Correct 27 ms 12660 KB Output is correct
30 Correct 27 ms 12716 KB Output is correct
31 Correct 24 ms 11108 KB Output is correct
32 Correct 24 ms 11116 KB Output is correct
33 Correct 25 ms 11640 KB Output is correct
34 Correct 25 ms 11648 KB Output is correct
35 Correct 27 ms 12492 KB Output is correct
36 Correct 28 ms 12424 KB Output is correct
37 Correct 28 ms 12592 KB Output is correct
38 Correct 35 ms 12416 KB Output is correct
39 Correct 27 ms 12400 KB Output is correct
40 Correct 27 ms 12392 KB Output is correct
41 Correct 28 ms 12984 KB Output is correct
42 Correct 27 ms 13012 KB Output is correct
43 Correct 30 ms 12908 KB Output is correct
44 Correct 30 ms 13228 KB Output is correct
45 Correct 36 ms 13476 KB Output is correct
46 Correct 28 ms 13120 KB Output is correct
47 Correct 26 ms 12192 KB Output is correct
48 Correct 27 ms 12308 KB Output is correct
49 Correct 27 ms 12200 KB Output is correct
50 Correct 27 ms 12208 KB Output is correct
51 Correct 25 ms 11156 KB Output is correct
52 Correct 27 ms 11100 KB Output is correct
53 Correct 24 ms 11180 KB Output is correct
54 Correct 26 ms 11180 KB Output is correct
55 Correct 24 ms 11172 KB Output is correct
56 Correct 24 ms 11212 KB Output is correct
57 Correct 25 ms 11444 KB Output is correct
58 Correct 25 ms 11372 KB Output is correct
59 Correct 25 ms 11128 KB Output is correct
60 Correct 27 ms 11428 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 11136 KB Output is correct
2 Correct 26 ms 12380 KB Output is correct
3 Correct 0 ms 792 KB Output is correct
4 Correct 20 ms 10884 KB Output is correct
5 Correct 30 ms 14000 KB Output is correct
6 Correct 31 ms 14008 KB Output is correct
7 Correct 26 ms 12864 KB Output is correct
8 Correct 26 ms 13044 KB Output is correct
9 Correct 30 ms 13940 KB Output is correct
10 Correct 30 ms 13988 KB Output is correct
11 Correct 30 ms 14000 KB Output is correct
12 Correct 30 ms 13856 KB Output is correct
13 Correct 34 ms 14052 KB Output is correct
14 Correct 31 ms 14208 KB Output is correct
15 Correct 30 ms 13964 KB Output is correct
16 Correct 30 ms 14472 KB Output is correct
17 Correct 28 ms 14220 KB Output is correct
18 Correct 27 ms 14200 KB Output is correct
19 Correct 34 ms 13964 KB Output is correct
20 Correct 28 ms 13980 KB Output is correct
21 Correct 27 ms 14212 KB Output is correct
22 Correct 30 ms 14112 KB Output is correct
23 Correct 24 ms 11444 KB Output is correct
24 Correct 24 ms 11376 KB Output is correct
25 Correct 24 ms 12124 KB Output is correct
26 Correct 24 ms 12328 KB Output is correct
27 Correct 27 ms 13072 KB Output is correct
28 Correct 27 ms 13144 KB Output is correct
29 Correct 30 ms 13064 KB Output is correct
30 Correct 30 ms 13172 KB Output is correct
31 Correct 24 ms 11400 KB Output is correct
32 Correct 25 ms 11396 KB Output is correct
33 Correct 31 ms 12124 KB Output is correct
34 Correct 26 ms 12000 KB Output is correct
35 Correct 31 ms 12960 KB Output is correct
36 Correct 27 ms 12896 KB Output is correct
37 Correct 30 ms 12888 KB Output is correct
38 Correct 28 ms 12756 KB Output is correct
39 Correct 27 ms 12880 KB Output is correct
40 Correct 27 ms 12896 KB Output is correct
41 Correct 28 ms 13372 KB Output is correct
42 Correct 28 ms 13652 KB Output is correct
43 Correct 28 ms 13444 KB Output is correct
44 Correct 30 ms 13604 KB Output is correct
45 Correct 36 ms 13912 KB Output is correct
46 Correct 27 ms 13648 KB Output is correct
47 Correct 27 ms 12680 KB Output is correct
48 Correct 27 ms 12736 KB Output is correct
49 Correct 30 ms 12420 KB Output is correct
50 Correct 29 ms 12724 KB Output is correct
51 Correct 24 ms 11516 KB Output is correct
52 Correct 24 ms 11632 KB Output is correct
53 Correct 25 ms 11652 KB Output is correct
54 Correct 24 ms 11612 KB Output is correct
55 Correct 24 ms 11608 KB Output is correct
56 Correct 27 ms 11568 KB Output is correct
57 Correct 24 ms 11868 KB Output is correct
58 Correct 25 ms 11772 KB Output is correct
59 Correct 25 ms 11684 KB Output is correct
60 Correct 24 ms 11608 KB Output is correct