Submission #924226

# Submission time Handle Problem Language Result Execution time Memory
924226 2024-02-08T16:38:25 Z Tuanlinh123 Stray Cat (JOI20_stray) C++17
15 / 100
40 ms 16268 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;
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 (cnt==1)
    {
        ll s=0; for (ll i:y) s+=i;
        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[last]) {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 27 ms 14696 KB Output is correct
4 Correct 33 ms 16268 KB Output is correct
5 Correct 33 ms 16248 KB Output is correct
6 Correct 28 ms 15016 KB Output is correct
7 Correct 28 ms 15020 KB Output is correct
8 Correct 40 ms 15728 KB Output is correct
9 Correct 32 ms 15696 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 27 ms 14696 KB Output is correct
4 Correct 33 ms 16268 KB Output is correct
5 Correct 33 ms 16248 KB Output is correct
6 Correct 28 ms 15016 KB Output is correct
7 Correct 28 ms 15020 KB Output is correct
8 Correct 40 ms 15728 KB Output is correct
9 Correct 32 ms 15696 KB Output is correct
10 Correct 25 ms 13104 KB Output is correct
11 Correct 25 ms 13192 KB Output is correct
12 Correct 25 ms 13188 KB Output is correct
13 Correct 27 ms 13168 KB Output is correct
14 Correct 26 ms 13432 KB Output is correct
15 Correct 27 ms 13632 KB Output is correct
16 Correct 31 ms 15772 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 12764 KB Output is correct
2 Correct 0 ms 792 KB Output is correct
3 Correct 22 ms 12416 KB Output is correct
4 Correct 32 ms 14212 KB Output is correct
5 Correct 32 ms 14208 KB Output is correct
6 Correct 27 ms 12708 KB Output is correct
7 Correct 26 ms 12712 KB Output is correct
8 Correct 37 ms 13416 KB Output is correct
9 Correct 28 ms 13476 KB Output is correct
10 Correct 28 ms 13232 KB Output is correct
11 Correct 37 ms 13216 KB Output is correct
12 Correct 32 ms 13228 KB Output is correct
13 Correct 27 ms 13148 KB Output is correct
14 Correct 30 ms 13484 KB Output is correct
15 Correct 28 ms 13620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 12764 KB Output is correct
2 Correct 0 ms 792 KB Output is correct
3 Correct 22 ms 12416 KB Output is correct
4 Correct 32 ms 14212 KB Output is correct
5 Correct 32 ms 14208 KB Output is correct
6 Correct 27 ms 12708 KB Output is correct
7 Correct 26 ms 12712 KB Output is correct
8 Correct 37 ms 13416 KB Output is correct
9 Correct 28 ms 13476 KB Output is correct
10 Correct 28 ms 13232 KB Output is correct
11 Correct 37 ms 13216 KB Output is correct
12 Correct 32 ms 13228 KB Output is correct
13 Correct 27 ms 13148 KB Output is correct
14 Correct 30 ms 13484 KB Output is correct
15 Correct 28 ms 13620 KB Output is correct
16 Correct 23 ms 11168 KB Output is correct
17 Correct 23 ms 11240 KB Output is correct
18 Correct 25 ms 11260 KB Output is correct
19 Correct 25 ms 11040 KB Output is correct
20 Correct 27 ms 11900 KB Output is correct
21 Correct 30 ms 11644 KB Output is correct
22 Correct 28 ms 13620 KB Output is correct
23 Correct 24 ms 11368 KB Output is correct
24 Correct 25 ms 11360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1052 KB Output is correct
2 Correct 0 ms 1288 KB Output is correct
3 Correct 1 ms 1048 KB Output is correct
4 Correct 2 ms 1044 KB Output is correct
5 Correct 2 ms 1044 KB Output is correct
6 Incorrect 2 ms 1052 KB Wrong Answer [5]
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 24 ms 11216 KB Output is correct
2 Correct 27 ms 12448 KB Output is correct
3 Correct 1 ms 780 KB Output is correct
4 Correct 20 ms 10876 KB Output is correct
5 Correct 31 ms 13984 KB Output is correct
6 Correct 36 ms 14152 KB Output is correct
7 Correct 27 ms 12904 KB Output is correct
8 Incorrect 28 ms 13444 KB Wrong Answer [5]
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 26 ms 11136 KB Output is correct
2 Correct 27 ms 12480 KB Output is correct
3 Correct 0 ms 1296 KB Output is correct
4 Correct 27 ms 10876 KB Output is correct
5 Correct 35 ms 14000 KB Output is correct
6 Correct 31 ms 13992 KB Output is correct
7 Incorrect 24 ms 12976 KB Wrong Answer [5]
8 Halted 0 ms 0 KB -