Submission #260853

# Submission time Handle Problem Language Result Execution time Memory
260853 2020-08-11T05:55:22 Z 최은수(#5044) Stray Cat (JOI20_stray) C++17
100 / 100
69 ms 16480 KB
#include"Anthony.h"
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18;
vector<int>Mark(int N,int M,int A,int B,vector<int>U,vector<int>V)
{
    int n=N;
    int m=M;
    int a=min(A,3);
    vector<vector<int> >adj(n);
    for(int i=0;i<m;i++)
        adj[U[i]].eb(V[i]),adj[V[i]].eb(U[i]);
    vector<int>dis(n,inf);
    queue<int>q;
    dis[0]=0;
    q.ep(0);
    while(!q.empty())
    {
        int x=q.front();
        q.pop();
        for(int&t:adj[x])
            if(dis[t]==inf)
                dis[t]=dis[x]+1,q.ep(t);
    }
    vector<int>col(m,0);
    if(a==2)
    {
        const int pat[6]={0,0,1,0,1,1};
        vector<int>pai(n,-1);
        for(int i=0;i<m;i++)
            pai[dis[U[i]]>dis[V[i]]?U[i]:V[i]]=i;
        fill(all(dis),inf);
        dis[0]=0;
        q.ep(0);
        while(!q.empty())
        {
            int x=q.front();
            q.pop();
            if(x!=0)
                col[pai[x]]=pat[dis[x]];
            for(int&t:adj[x])
            {
                if(dis[t]==inf)
                {
                    if(x==0)
                        dis[t]=0;
                    else if((int)adj[x].size()>2)
                        dis[t]=5-dis[x];
                    else
                        dis[t]=(dis[x]+1)%6;
                    q.ep(t);
                }
            }
        }
    }
    else
        for(int i=0;i<m;i++)
            col[i]=(dis[U[i]]+dis[V[i]])/2%a;
    return col;
}
#include"Catherine.h"
#include<iostream>
#include<vector>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18;
static int a,prv,cnt,cur;
static int type;
static bool cor;
void Init(int A,int B)
{
    type=prv=-1;
    cor=0;
    cur=cnt=0;
    a=min(A,3);
    return;
}
int Move(vector<int>y)
{
    if(a==2)
    {
        if((prv!=-1?1:0)+y[0]+y[1]>=3)
        {
            cor=1;
            if(y[0]==0||y[1]==0)
                return-1;
            if(prv==-1)
                return prv=y[0]==1?0:1;
            return prv^=1;
        }
        if((prv!=-1?1:0)+y[0]+y[1]==1)
        {
            cor=1;
            if(y[0]==1)
                return prv=0;
            if(y[1]==1)
                return prv=1;
            return-1;
        }
        if(cor)
            return prv=y[0]==1?0:1;
        cnt++;
        if(prv==-1)
        {
            if(y[1]==0)
            {
                type=0;
                return prv=cur=0;
            }
            if(y[0]==0)
            {
                type=2;
                return prv=cur=1;
            }
            type=1;
            return prv=cur=1;
        }
        int nx=y[0]==1?0:1;
        cur=cur*2+nx;
        if(cnt==4)
        {
            cor=1;
            if(cur==5||cur==11||cur==12||(cur==9&&type==2))
                return-1;
            return prv=nx;
        }
        return prv=nx;
    }
    int c=0;
    for(int i=0;i<3;i++)
        if(y[i]>0)
            c+=3+i;
    if(c<6)
        return c-3;
    for(int i=0;i<3;i++)
        if(y[i]==0)
            return(i+1)%3;
    return a;
}
# Verdict Execution time Memory Grader output
1 Correct 55 ms 15228 KB Output is correct
2 Correct 1 ms 780 KB Output is correct
3 Correct 48 ms 14640 KB Output is correct
4 Correct 65 ms 16480 KB Output is correct
5 Correct 69 ms 16244 KB Output is correct
6 Correct 54 ms 15092 KB Output is correct
7 Correct 55 ms 14964 KB Output is correct
8 Correct 63 ms 15732 KB Output is correct
9 Correct 61 ms 15824 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 55 ms 15228 KB Output is correct
2 Correct 1 ms 780 KB Output is correct
3 Correct 48 ms 14640 KB Output is correct
4 Correct 65 ms 16480 KB Output is correct
5 Correct 69 ms 16244 KB Output is correct
6 Correct 54 ms 15092 KB Output is correct
7 Correct 55 ms 14964 KB Output is correct
8 Correct 63 ms 15732 KB Output is correct
9 Correct 61 ms 15824 KB Output is correct
10 Correct 44 ms 13048 KB Output is correct
11 Correct 44 ms 12920 KB Output is correct
12 Correct 44 ms 13172 KB Output is correct
13 Correct 47 ms 13116 KB Output is correct
14 Correct 46 ms 13448 KB Output is correct
15 Correct 52 ms 13576 KB Output is correct
16 Correct 57 ms 15860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 51 ms 12788 KB Output is correct
2 Correct 1 ms 784 KB Output is correct
3 Correct 40 ms 12324 KB Output is correct
4 Correct 60 ms 14304 KB Output is correct
5 Correct 62 ms 14428 KB Output is correct
6 Correct 50 ms 12920 KB Output is correct
7 Correct 47 ms 12860 KB Output is correct
8 Correct 54 ms 13556 KB Output is correct
9 Correct 60 ms 13604 KB Output is correct
10 Correct 52 ms 13416 KB Output is correct
11 Correct 52 ms 13172 KB Output is correct
12 Correct 55 ms 13400 KB Output is correct
13 Correct 55 ms 13452 KB Output is correct
14 Correct 54 ms 13564 KB Output is correct
15 Correct 54 ms 13556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 51 ms 12788 KB Output is correct
2 Correct 1 ms 784 KB Output is correct
3 Correct 40 ms 12324 KB Output is correct
4 Correct 60 ms 14304 KB Output is correct
5 Correct 62 ms 14428 KB Output is correct
6 Correct 50 ms 12920 KB Output is correct
7 Correct 47 ms 12860 KB Output is correct
8 Correct 54 ms 13556 KB Output is correct
9 Correct 60 ms 13604 KB Output is correct
10 Correct 52 ms 13416 KB Output is correct
11 Correct 52 ms 13172 KB Output is correct
12 Correct 55 ms 13400 KB Output is correct
13 Correct 55 ms 13452 KB Output is correct
14 Correct 54 ms 13564 KB Output is correct
15 Correct 54 ms 13556 KB Output is correct
16 Correct 41 ms 11128 KB Output is correct
17 Correct 41 ms 11176 KB Output is correct
18 Correct 43 ms 11120 KB Output is correct
19 Correct 43 ms 11248 KB Output is correct
20 Correct 50 ms 11652 KB Output is correct
21 Correct 46 ms 11384 KB Output is correct
22 Correct 55 ms 13688 KB Output is correct
23 Correct 44 ms 11128 KB Output is correct
24 Correct 44 ms 11264 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1124 KB Output is correct
2 Correct 0 ms 772 KB Output is correct
3 Correct 2 ms 1124 KB Output is correct
4 Correct 2 ms 1036 KB Output is correct
5 Correct 2 ms 1036 KB Output is correct
6 Correct 2 ms 1036 KB Output is correct
7 Correct 2 ms 1036 KB Output is correct
8 Correct 2 ms 1132 KB Output is correct
9 Correct 2 ms 1036 KB Output is correct
10 Correct 2 ms 1128 KB Output is correct
11 Correct 2 ms 1036 KB Output is correct
12 Correct 2 ms 1036 KB Output is correct
13 Correct 2 ms 1036 KB Output is correct
14 Correct 2 ms 1136 KB Output is correct
15 Correct 2 ms 1036 KB Output is correct
16 Correct 2 ms 1036 KB Output is correct
17 Correct 2 ms 1124 KB Output is correct
18 Correct 2 ms 1036 KB Output is correct
19 Correct 2 ms 1120 KB Output is correct
20 Correct 2 ms 1036 KB Output is correct
21 Correct 2 ms 1132 KB Output is correct
22 Correct 2 ms 1036 KB Output is correct
23 Correct 2 ms 1036 KB Output is correct
24 Correct 2 ms 1036 KB Output is correct
25 Correct 2 ms 1136 KB Output is correct
26 Correct 2 ms 908 KB Output is correct
27 Correct 2 ms 1036 KB Output is correct
28 Correct 2 ms 1128 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 46 ms 11064 KB Output is correct
2 Correct 49 ms 11560 KB Output is correct
3 Correct 0 ms 780 KB Output is correct
4 Correct 38 ms 11000 KB Output is correct
5 Correct 54 ms 12404 KB Output is correct
6 Correct 56 ms 12156 KB Output is correct
7 Correct 52 ms 11516 KB Output is correct
8 Correct 46 ms 11932 KB Output is correct
9 Correct 57 ms 12620 KB Output is correct
10 Correct 60 ms 12740 KB Output is correct
11 Correct 55 ms 12688 KB Output is correct
12 Correct 60 ms 12696 KB Output is correct
13 Correct 56 ms 12956 KB Output is correct
14 Correct 57 ms 12824 KB Output is correct
15 Correct 59 ms 12692 KB Output is correct
16 Correct 56 ms 12740 KB Output is correct
17 Correct 52 ms 12436 KB Output is correct
18 Correct 53 ms 12376 KB Output is correct
19 Correct 53 ms 12236 KB Output is correct
20 Correct 53 ms 12440 KB Output is correct
21 Correct 53 ms 12364 KB Output is correct
22 Correct 53 ms 12440 KB Output is correct
23 Correct 45 ms 11440 KB Output is correct
24 Correct 45 ms 11380 KB Output is correct
25 Correct 46 ms 11648 KB Output is correct
26 Correct 46 ms 11468 KB Output is correct
27 Correct 52 ms 11852 KB Output is correct
28 Correct 51 ms 11852 KB Output is correct
29 Correct 54 ms 11972 KB Output is correct
30 Correct 53 ms 12056 KB Output is correct
31 Correct 46 ms 11508 KB Output is correct
32 Correct 45 ms 11512 KB Output is correct
33 Correct 46 ms 11632 KB Output is correct
34 Correct 46 ms 11464 KB Output is correct
35 Correct 53 ms 11852 KB Output is correct
36 Correct 53 ms 12016 KB Output is correct
37 Correct 51 ms 11972 KB Output is correct
38 Correct 60 ms 11844 KB Output is correct
39 Correct 59 ms 12040 KB Output is correct
40 Correct 52 ms 12044 KB Output is correct
41 Correct 63 ms 12284 KB Output is correct
42 Correct 59 ms 12292 KB Output is correct
43 Correct 52 ms 12292 KB Output is correct
44 Correct 53 ms 12304 KB Output is correct
45 Correct 68 ms 12440 KB Output is correct
46 Correct 56 ms 12304 KB Output is correct
47 Correct 49 ms 12020 KB Output is correct
48 Correct 49 ms 11724 KB Output is correct
49 Correct 48 ms 11772 KB Output is correct
50 Correct 52 ms 12000 KB Output is correct
51 Correct 47 ms 11468 KB Output is correct
52 Correct 45 ms 11392 KB Output is correct
53 Correct 45 ms 11392 KB Output is correct
54 Correct 47 ms 11400 KB Output is correct
55 Correct 47 ms 11212 KB Output is correct
56 Correct 46 ms 11380 KB Output is correct
57 Correct 48 ms 11596 KB Output is correct
58 Correct 49 ms 11672 KB Output is correct
59 Correct 49 ms 11832 KB Output is correct
60 Correct 46 ms 11588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 50 ms 10996 KB Output is correct
2 Correct 47 ms 11132 KB Output is correct
3 Correct 1 ms 784 KB Output is correct
4 Correct 39 ms 11128 KB Output is correct
5 Correct 56 ms 12180 KB Output is correct
6 Correct 66 ms 12188 KB Output is correct
7 Correct 54 ms 11388 KB Output is correct
8 Correct 59 ms 11716 KB Output is correct
9 Correct 57 ms 12896 KB Output is correct
10 Correct 64 ms 12612 KB Output is correct
11 Correct 56 ms 12700 KB Output is correct
12 Correct 68 ms 12692 KB Output is correct
13 Correct 62 ms 12788 KB Output is correct
14 Correct 57 ms 12816 KB Output is correct
15 Correct 56 ms 12612 KB Output is correct
16 Correct 61 ms 12812 KB Output is correct
17 Correct 61 ms 12356 KB Output is correct
18 Correct 52 ms 12436 KB Output is correct
19 Correct 63 ms 12388 KB Output is correct
20 Correct 53 ms 12432 KB Output is correct
21 Correct 53 ms 12444 KB Output is correct
22 Correct 57 ms 12368 KB Output is correct
23 Correct 45 ms 11364 KB Output is correct
24 Correct 43 ms 11352 KB Output is correct
25 Correct 49 ms 11484 KB Output is correct
26 Correct 55 ms 11628 KB Output is correct
27 Correct 64 ms 12192 KB Output is correct
28 Correct 55 ms 12032 KB Output is correct
29 Correct 61 ms 12044 KB Output is correct
30 Correct 53 ms 12044 KB Output is correct
31 Correct 57 ms 11332 KB Output is correct
32 Correct 45 ms 11340 KB Output is correct
33 Correct 46 ms 11644 KB Output is correct
34 Correct 47 ms 11616 KB Output is correct
35 Correct 52 ms 11852 KB Output is correct
36 Correct 53 ms 12028 KB Output is correct
37 Correct 60 ms 12148 KB Output is correct
38 Correct 50 ms 11876 KB Output is correct
39 Correct 50 ms 12308 KB Output is correct
40 Correct 49 ms 12036 KB Output is correct
41 Correct 54 ms 12288 KB Output is correct
42 Correct 54 ms 12320 KB Output is correct
43 Correct 52 ms 12100 KB Output is correct
44 Correct 57 ms 12292 KB Output is correct
45 Correct 56 ms 12308 KB Output is correct
46 Correct 63 ms 12292 KB Output is correct
47 Correct 51 ms 12156 KB Output is correct
48 Correct 53 ms 11904 KB Output is correct
49 Correct 51 ms 11736 KB Output is correct
50 Correct 56 ms 11852 KB Output is correct
51 Correct 50 ms 11212 KB Output is correct
52 Correct 49 ms 11340 KB Output is correct
53 Correct 46 ms 11396 KB Output is correct
54 Correct 48 ms 11404 KB Output is correct
55 Correct 47 ms 11548 KB Output is correct
56 Correct 46 ms 11340 KB Output is correct
57 Correct 48 ms 11596 KB Output is correct
58 Correct 46 ms 11792 KB Output is correct
59 Correct 46 ms 11668 KB Output is correct
60 Correct 48 ms 11776 KB Output is correct