Submission #924212

# Submission time Handle Problem Language Result Execution time Memory
924212 2024-02-08T16:30:13 Z Tuanlinh123 Stray Cat (JOI20_stray) C++17
15 / 100
41 ms 16280 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)
    {
        if (y[0]==1 && y[1]==1) {crr="01"; return last=1;}
        else ok=1;
        if (y[0]>1) return last=1;
        if (y[1]>1) return last=0;
        if (!y[0]) return last=1;
        if (!y[1]) return last=0;
    }
    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 1 ms 776 KB Output is correct
3 Correct 28 ms 14708 KB Output is correct
4 Correct 34 ms 16252 KB Output is correct
5 Correct 33 ms 16280 KB Output is correct
6 Correct 26 ms 15020 KB Output is correct
7 Correct 28 ms 15084 KB Output is correct
8 Correct 31 ms 15772 KB Output is correct
9 Correct 31 ms 15796 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 15268 KB Output is correct
2 Correct 1 ms 776 KB Output is correct
3 Correct 28 ms 14708 KB Output is correct
4 Correct 34 ms 16252 KB Output is correct
5 Correct 33 ms 16280 KB Output is correct
6 Correct 26 ms 15020 KB Output is correct
7 Correct 28 ms 15084 KB Output is correct
8 Correct 31 ms 15772 KB Output is correct
9 Correct 31 ms 15796 KB Output is correct
10 Correct 25 ms 13180 KB Output is correct
11 Correct 25 ms 13184 KB Output is correct
12 Correct 25 ms 13184 KB Output is correct
13 Correct 25 ms 12988 KB Output is correct
14 Correct 26 ms 13452 KB Output is correct
15 Correct 26 ms 13688 KB Output is correct
16 Correct 30 ms 15712 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 12704 KB Output is correct
2 Correct 0 ms 792 KB Output is correct
3 Correct 22 ms 12416 KB Output is correct
4 Correct 41 ms 14068 KB Output is correct
5 Correct 31 ms 14216 KB Output is correct
6 Correct 26 ms 12964 KB Output is correct
7 Correct 25 ms 12720 KB Output is correct
8 Correct 28 ms 13472 KB Output is correct
9 Correct 30 ms 13488 KB Output is correct
10 Correct 27 ms 13228 KB Output is correct
11 Correct 36 ms 13260 KB Output is correct
12 Correct 30 ms 13128 KB Output is correct
13 Correct 27 ms 13220 KB Output is correct
14 Correct 28 ms 13452 KB Output is correct
15 Correct 28 ms 13472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 12704 KB Output is correct
2 Correct 0 ms 792 KB Output is correct
3 Correct 22 ms 12416 KB Output is correct
4 Correct 41 ms 14068 KB Output is correct
5 Correct 31 ms 14216 KB Output is correct
6 Correct 26 ms 12964 KB Output is correct
7 Correct 25 ms 12720 KB Output is correct
8 Correct 28 ms 13472 KB Output is correct
9 Correct 30 ms 13488 KB Output is correct
10 Correct 27 ms 13228 KB Output is correct
11 Correct 36 ms 13260 KB Output is correct
12 Correct 30 ms 13128 KB Output is correct
13 Correct 27 ms 13220 KB Output is correct
14 Correct 28 ms 13452 KB Output is correct
15 Correct 28 ms 13472 KB Output is correct
16 Correct 23 ms 11256 KB Output is correct
17 Correct 26 ms 11340 KB Output is correct
18 Correct 24 ms 11132 KB Output is correct
19 Correct 24 ms 11332 KB Output is correct
20 Correct 26 ms 11888 KB Output is correct
21 Correct 25 ms 11656 KB Output is correct
22 Correct 31 ms 13700 KB Output is correct
23 Correct 24 ms 11272 KB Output is correct
24 Correct 25 ms 11376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1048 KB Output is correct
2 Correct 0 ms 784 KB Output is correct
3 Correct 1 ms 1040 KB Output is correct
4 Correct 2 ms 1056 KB Output is correct
5 Correct 1 ms 1052 KB Output is correct
6 Incorrect 2 ms 1056 KB Wrong Answer [5]
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 27 ms 11152 KB Output is correct
2 Correct 27 ms 12976 KB Output is correct
3 Correct 1 ms 784 KB Output is correct
4 Correct 20 ms 11060 KB Output is correct
5 Correct 30 ms 14452 KB Output is correct
6 Correct 30 ms 14452 KB Output is correct
7 Incorrect 24 ms 13512 KB Wrong Answer [5]
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 24 ms 11132 KB Output is correct
2 Correct 29 ms 12816 KB Output is correct
3 Correct 0 ms 796 KB Output is correct
4 Correct 20 ms 11116 KB Output is correct
5 Correct 30 ms 14464 KB Output is correct
6 Correct 30 ms 14464 KB Output is correct
7 Incorrect 24 ms 13448 KB Wrong Answer [5]
8 Halted 0 ms 0 KB -