답안 #1061654

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1061654 2024-08-16T11:28:00 Z Hanksburger 길고양이 (JOI20_stray) C++17
15 / 100
35 ms 17268 KB
#include "Anthony.h"
#include <bits/stdc++.h>
using namespace std;
int d[20005], c[20005], e[20005], p[20005];
vector<int> adj[20005];
queue<int> q;
void dfs(int u)
{
    for (int v:adj[u])
    {
        if (v==p[u])
            continue;
        p[v]=u;
        c[v]=!c[u];
        if (adj[v].size()>=3)
            dfs(v);
        else
            q.push(v);
    }
}
void dfs2(int u)
{
    for (int v:adj[u])
    {
        if (v==p[u])
            continue;
        p[v]=u;
        e[v]=(e[u]+1)%6;
        if (e[v]==2 || e[v]==4 || e[v]==5)
            c[v]=1;
        if (adj[v].size()>=3)
            q.push(v);
        else
            dfs2(v);
    }
}
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]);
        adj[V[i]].push_back(U[i]);
    }
    if (A>2)
    {
        d[0]=1;
        q.push(0);
        while (!q.empty())
        {
            int u=q.front();
            q.pop();
            for (int v:adj[u])
            {
                if (!d[v])
                {
                    d[v]=d[u]+1;
                    q.push(v);
                }
            }
        }
        vector<int> ans;
        for (int i=0; i<M; i++)
            ans.push_back(min(d[U[i]], d[V[i]])%3);
        return ans;
    }
    q.push(0);
    while (!q.empty())
    {
        int u=q.front();
        q.pop();
        if ((u==0 && adj[u].size()>=2) || adj[u].size()>=3)
            dfs(u);
        else
        {
            if (c[u])
                e[u]=5;
            dfs2(u);
        }
    }
    vector<int> ans;
    for (int i=0; i<M; i++)
    {
        if (U[i]==p[V[i]])
            ans.push_back(c[V[i]]);
        else
            ans.push_back(c[U[i]]);
        //cout << ans[i] << ' ';
    }
    //cout << '\n';
    return ans;
}
#include "Catherine.h"
#include <bits/stdc++.h>
using namespace std;
int a, pre=2, ok;
vector<int> vec;
void Init(int A, int B)
{
    a=A;
}
int Move(vector<int> y)
{
    if (a>2)
    {
        if (y[0] && !y[2])
            return 0;
        else if (y[1] && !y[0])
            return 1;
        else
            return 2;
    }
    if (pre==2)
    {
        if (y[0]+y[1]==1 || y[0]+y[1]>=3)
        {
            ok=1;
            if (y[0]==1)
            {
                pre=0;
                return 0;
            }
            else
            {
                pre=1;
                return 1;
            }
        }
        else
        {
            if (y[0]==2)
            {
                vec.push_back(0);
                //cout << "vec push " << vec[0] << '\n';
                pre=0;
                return 0;
            }
            else if (y[1]==2)
            {
                vec.push_back(1);
                //cout << "vec push " << vec[0] << '\n';
                pre=1;
                return 1;
            }
            else
            {
                vec.push_back(1);
                //cout << "vec push " << vec[0] << '\n';
                pre=0;
                return 0;
            }
        }
    }
    else
    {
        if (y[0]+y[1]==0)
        {
            //cout << "im here 1\n";
            ok=1;
            return -1;
        }
        else if (y[0]+y[1]>=2)
        {
            //cout << "im here 2\n";
            ok=1;
            y[pre]++;
            if (y[0]==1)
            {
                pre=0;
                return 0;
            }
            else
            {
                pre=1;
                return 1;
            }
        }
        else if (ok)
        {
            //cout << "im here 3\n";
            if (y[0]==1)
            {
                pre=0;
                return 0;
            }
            else
            {
                pre=1;
                return 1;
            }
        }
        else
        {
            vec.push_back(pre);
            //cout << "vec push " << pre << '\n';
            if (vec.size()==4)
            {
                ok=1;
                if (y[0])
                    vec.push_back(0);
                else
                    vec.push_back(1);
                if ((vec[0]==0 && vec[1]==0 && vec[2]==1 && vec[3]==0 && vec[4]==1) ||
                    (vec[0]==0 && vec[1]==1 && vec[2]==0 && vec[3]==1 && vec[4]==1) ||
                    (vec[0]==1 && vec[1]==0 && vec[2]==1 && vec[3]==1 && vec[4]==0) ||
                    (vec[0]==0 && vec[1]==1 && vec[2]==1 && vec[3]==0 && vec[4]==0) ||
                    (vec[0]==1 && vec[1]==1 && vec[2]==0 && vec[3]==0 && vec[4]==1) ||
                    (vec[0]==1 && vec[1]==0 && vec[2]==0 && vec[3]==1 && vec[4]==0))
                    return -1;
                else
                {
                    if (y[0])
                    {
                        pre=0;
                        return 0;
                    }
                    else
                    {
                        pre=1;
                        return 1;
                    }
                }
            }
            else
            {
                if (y[0])
                {
                    pre=0;
                    return 0;
                }
                else
                {
                    pre=1;
                    return 1;
                }
            }
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 16200 KB Output is correct
2 Correct 1 ms 1312 KB Output is correct
3 Correct 30 ms 15432 KB Output is correct
4 Correct 31 ms 17164 KB Output is correct
5 Correct 32 ms 17268 KB Output is correct
6 Correct 26 ms 15884 KB Output is correct
7 Correct 25 ms 15884 KB Output is correct
8 Correct 35 ms 16792 KB Output is correct
9 Correct 30 ms 16732 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 16200 KB Output is correct
2 Correct 1 ms 1312 KB Output is correct
3 Correct 30 ms 15432 KB Output is correct
4 Correct 31 ms 17164 KB Output is correct
5 Correct 32 ms 17268 KB Output is correct
6 Correct 26 ms 15884 KB Output is correct
7 Correct 25 ms 15884 KB Output is correct
8 Correct 35 ms 16792 KB Output is correct
9 Correct 30 ms 16732 KB Output is correct
10 Correct 23 ms 14072 KB Output is correct
11 Correct 23 ms 14140 KB Output is correct
12 Correct 23 ms 14168 KB Output is correct
13 Correct 25 ms 14276 KB Output is correct
14 Correct 26 ms 14160 KB Output is correct
15 Correct 30 ms 14352 KB Output is correct
16 Correct 30 ms 16732 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 13700 KB Output is correct
2 Correct 1 ms 1308 KB Output is correct
3 Correct 19 ms 13084 KB Output is correct
4 Correct 29 ms 15184 KB Output is correct
5 Correct 29 ms 15092 KB Output is correct
6 Correct 26 ms 13660 KB Output is correct
7 Correct 26 ms 13660 KB Output is correct
8 Correct 28 ms 14416 KB Output is correct
9 Correct 27 ms 14416 KB Output is correct
10 Correct 27 ms 14164 KB Output is correct
11 Correct 34 ms 14156 KB Output is correct
12 Correct 28 ms 14136 KB Output is correct
13 Correct 25 ms 14092 KB Output is correct
14 Correct 32 ms 14416 KB Output is correct
15 Correct 28 ms 14492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 13700 KB Output is correct
2 Correct 1 ms 1308 KB Output is correct
3 Correct 19 ms 13084 KB Output is correct
4 Correct 29 ms 15184 KB Output is correct
5 Correct 29 ms 15092 KB Output is correct
6 Correct 26 ms 13660 KB Output is correct
7 Correct 26 ms 13660 KB Output is correct
8 Correct 28 ms 14416 KB Output is correct
9 Correct 27 ms 14416 KB Output is correct
10 Correct 27 ms 14164 KB Output is correct
11 Correct 34 ms 14156 KB Output is correct
12 Correct 28 ms 14136 KB Output is correct
13 Correct 25 ms 14092 KB Output is correct
14 Correct 32 ms 14416 KB Output is correct
15 Correct 28 ms 14492 KB Output is correct
16 Correct 32 ms 12052 KB Output is correct
17 Correct 25 ms 12084 KB Output is correct
18 Correct 23 ms 12104 KB Output is correct
19 Correct 26 ms 12064 KB Output is correct
20 Correct 26 ms 12624 KB Output is correct
21 Correct 24 ms 12356 KB Output is correct
22 Correct 30 ms 14588 KB Output is correct
23 Correct 24 ms 12120 KB Output is correct
24 Correct 26 ms 12092 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 1572 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 11748 KB Output is correct
2 Incorrect 25 ms 11848 KB Wrong Answer [5]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 23 ms 12116 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -