답안 #260893

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
260893 2020-08-11T07:10:38 Z 문홍윤(#5067) 길고양이 (JOI20_stray) C++17
100 / 100
76 ms 16988 KB
#include "Anthony.h"
#include <bits/stdc++.h>
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
using namespace std;
typedef pair<int, int> pii;
static const int INF=1e9;

static int n, m, col[20010];
static vector<pii> link[20010];

static int que[20010], fr, re, d[20010];
static void col_typeA(){
    que[++re]=0;
    d[0]=1;
    for(fr=1; fr<=re; fr++){
        for(auto i:link[que[fr]]){
            if(d[i.F])continue;
            d[i.F]=d[que[fr]]+1;
            que[++re]=i.F;
        }
    }
    for(int i=0; i<n; i++){
        for(auto j:link[i]){
            int tmp=min(d[i], d[j.F]);
            col[j.S]=tmp%3+1;
        }
    }
}
static int rpt[6]={0, 1, 0, 0, 1, 1};
static void dfs(int num, int par, int uc){
    int tmp=link[num].size();
    if(!num)tmp++;
    int nxt=1-rpt[uc];
    if(tmp==2)nxt=(uc+1)%6;
    for(auto i:link[num]){
        if(i.F==par)continue;
        col[i.S]=rpt[nxt];
        dfs(i.F, num, nxt);
    }
}
static void col_typeB(){dfs(0, -1, 0);}

vector<int> Mark(int N, int M, int A, int B, vector<int> U, vector<int> V){
    n=N, m=M;
    vector<int> ret(m);
    for(int i=0; i<m; i++){
        link[U[i]].eb(V[i], i);
        link[V[i]].eb(U[i], i);
    }
    if(A>=3)col_typeA();
    else col_typeB();
    for(int i=0; i<m; i++)ret[i]=col[i]-(A>=3);
    return ret;
}
#include "Catherine.h"
#include <bits/stdc++.h>
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
using namespace std;
typedef pair<int, int> pii;

static int typ;
void Init(int A, int B){
    if(A>=3)typ=1;
    else typ=2;
}

static int move_typeA(vector<int> vc){
    for(int i=0; i<3; i++)if(vc[i]&&!vc[(i+2)%3])return i;
}

static int rpt[6]={0, 1, 0, 0, 1, 1};
static bool fnd;
static int cnt, prv=-1, mask;
static int move_typeB(vector<int> vc){
    cnt++;
    int deg=vc[0]+vc[1];
    if(prv>=0)deg++;
    if(fnd){
        if(deg>=3){
            prv=1-prv;
            return prv;
        }
        if(vc[0])prv=0;
        else prv=1;
        return prv;
    }
    if(deg==1){
        fnd=true;
        if(cnt>1)return -1;
        if(vc[0])prv=0;
        else prv=1;
        return prv;
    }
    if(deg>=3){
        if(cnt>1)vc[prv]++;
        fnd=true;
        int tmp;
        if(vc[0]==1)tmp=0;
        else tmp=1;
        if(tmp==prv&&cnt>1)return -1;
        prv=tmp;
        return tmp;
    }
    if(cnt<=3){
        if(vc[0])prv=0;
        else prv=1;
        if(cnt==1)mask*=2, mask+=vc[1]-prv;
        mask*=2, mask+=prv;
        return prv;
    }
    if(cnt==4){
        fnd=true;
        int opp;
        if(vc[0])opp=0;
        else opp=1;
        mask*=2, mask+=opp;
        if(mask==25||mask==18||mask==5||mask==11||mask==22||mask==12){
            prv=opp;
            return prv;
        }
        return -1;
    }
}

int Move(vector<int> y){
    if(typ==1)return move_typeA(y);
    return move_typeB(y);
}

Compilation message

Catherine.cpp: In function 'int move_typeA(std::vector<int>)':
Catherine.cpp:18:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
Catherine.cpp: In function 'int move_typeB(std::vector<int>)':
Catherine.cpp:72:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
Catherine.cpp: At global scope:
Catherine.cpp:20:12: warning: 'rpt' defined but not used [-Wunused-variable]
 static int rpt[6]={0, 1, 0, 0, 1, 1};
            ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 54 ms 15992 KB Output is correct
2 Correct 2 ms 1536 KB Output is correct
3 Correct 41 ms 15128 KB Output is correct
4 Correct 66 ms 16988 KB Output is correct
5 Correct 68 ms 16756 KB Output is correct
6 Correct 49 ms 15716 KB Output is correct
7 Correct 50 ms 15716 KB Output is correct
8 Correct 62 ms 16272 KB Output is correct
9 Correct 63 ms 16244 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 54 ms 15992 KB Output is correct
2 Correct 2 ms 1536 KB Output is correct
3 Correct 41 ms 15128 KB Output is correct
4 Correct 66 ms 16988 KB Output is correct
5 Correct 68 ms 16756 KB Output is correct
6 Correct 49 ms 15716 KB Output is correct
7 Correct 50 ms 15716 KB Output is correct
8 Correct 62 ms 16272 KB Output is correct
9 Correct 63 ms 16244 KB Output is correct
10 Correct 62 ms 13552 KB Output is correct
11 Correct 47 ms 13732 KB Output is correct
12 Correct 51 ms 13560 KB Output is correct
13 Correct 47 ms 13724 KB Output is correct
14 Correct 56 ms 13984 KB Output is correct
15 Correct 56 ms 14372 KB Output is correct
16 Correct 63 ms 16508 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 48 ms 13436 KB Output is correct
2 Correct 1 ms 1536 KB Output is correct
3 Correct 68 ms 12796 KB Output is correct
4 Correct 71 ms 14768 KB Output is correct
5 Correct 74 ms 14708 KB Output is correct
6 Correct 51 ms 13536 KB Output is correct
7 Correct 54 ms 13524 KB Output is correct
8 Correct 57 ms 14100 KB Output is correct
9 Correct 60 ms 14068 KB Output is correct
10 Correct 54 ms 13820 KB Output is correct
11 Correct 54 ms 13836 KB Output is correct
12 Correct 54 ms 13820 KB Output is correct
13 Correct 61 ms 13828 KB Output is correct
14 Correct 58 ms 13920 KB Output is correct
15 Correct 70 ms 14148 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 48 ms 13436 KB Output is correct
2 Correct 1 ms 1536 KB Output is correct
3 Correct 68 ms 12796 KB Output is correct
4 Correct 71 ms 14768 KB Output is correct
5 Correct 74 ms 14708 KB Output is correct
6 Correct 51 ms 13536 KB Output is correct
7 Correct 54 ms 13524 KB Output is correct
8 Correct 57 ms 14100 KB Output is correct
9 Correct 60 ms 14068 KB Output is correct
10 Correct 54 ms 13820 KB Output is correct
11 Correct 54 ms 13836 KB Output is correct
12 Correct 54 ms 13820 KB Output is correct
13 Correct 61 ms 13828 KB Output is correct
14 Correct 58 ms 13920 KB Output is correct
15 Correct 70 ms 14148 KB Output is correct
16 Correct 48 ms 11964 KB Output is correct
17 Correct 43 ms 11768 KB Output is correct
18 Correct 57 ms 11760 KB Output is correct
19 Correct 43 ms 11820 KB Output is correct
20 Correct 52 ms 12408 KB Output is correct
21 Correct 46 ms 12152 KB Output is correct
22 Correct 55 ms 14352 KB Output is correct
23 Correct 45 ms 11900 KB Output is correct
24 Correct 44 ms 11768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1536 KB Output is correct
2 Correct 1 ms 1792 KB Output is correct
3 Correct 2 ms 1536 KB Output is correct
4 Correct 2 ms 1792 KB Output is correct
5 Correct 2 ms 1792 KB Output is correct
6 Correct 2 ms 1792 KB Output is correct
7 Correct 2 ms 1792 KB Output is correct
8 Correct 2 ms 1792 KB Output is correct
9 Correct 2 ms 1792 KB Output is correct
10 Correct 2 ms 1792 KB Output is correct
11 Correct 2 ms 1792 KB Output is correct
12 Correct 2 ms 1792 KB Output is correct
13 Correct 3 ms 1792 KB Output is correct
14 Correct 2 ms 1792 KB Output is correct
15 Correct 2 ms 1792 KB Output is correct
16 Correct 2 ms 1792 KB Output is correct
17 Correct 2 ms 1792 KB Output is correct
18 Correct 2 ms 1712 KB Output is correct
19 Correct 2 ms 1792 KB Output is correct
20 Correct 2 ms 1792 KB Output is correct
21 Correct 2 ms 1792 KB Output is correct
22 Correct 2 ms 1792 KB Output is correct
23 Correct 2 ms 1792 KB Output is correct
24 Correct 2 ms 1792 KB Output is correct
25 Correct 3 ms 1792 KB Output is correct
26 Correct 2 ms 1792 KB Output is correct
27 Correct 2 ms 1792 KB Output is correct
28 Correct 2 ms 1792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 11608 KB Output is correct
2 Correct 54 ms 12540 KB Output is correct
3 Correct 1 ms 1536 KB Output is correct
4 Correct 40 ms 11196 KB Output is correct
5 Correct 57 ms 13832 KB Output is correct
6 Correct 70 ms 13704 KB Output is correct
7 Correct 54 ms 12920 KB Output is correct
8 Correct 45 ms 13268 KB Output is correct
9 Correct 63 ms 14208 KB Output is correct
10 Correct 66 ms 14184 KB Output is correct
11 Correct 62 ms 14204 KB Output is correct
12 Correct 60 ms 14328 KB Output is correct
13 Correct 59 ms 14464 KB Output is correct
14 Correct 61 ms 14344 KB Output is correct
15 Correct 56 ms 14164 KB Output is correct
16 Correct 60 ms 14176 KB Output is correct
17 Correct 54 ms 13772 KB Output is correct
18 Correct 54 ms 13972 KB Output is correct
19 Correct 53 ms 14096 KB Output is correct
20 Correct 57 ms 13956 KB Output is correct
21 Correct 56 ms 13964 KB Output is correct
22 Correct 57 ms 13968 KB Output is correct
23 Correct 43 ms 11856 KB Output is correct
24 Correct 44 ms 11992 KB Output is correct
25 Correct 54 ms 12408 KB Output is correct
26 Correct 48 ms 12292 KB Output is correct
27 Correct 53 ms 13140 KB Output is correct
28 Correct 53 ms 13196 KB Output is correct
29 Correct 53 ms 13444 KB Output is correct
30 Correct 52 ms 13196 KB Output is correct
31 Correct 49 ms 11724 KB Output is correct
32 Correct 45 ms 11860 KB Output is correct
33 Correct 45 ms 12268 KB Output is correct
34 Correct 45 ms 12280 KB Output is correct
35 Correct 55 ms 12876 KB Output is correct
36 Correct 54 ms 12876 KB Output is correct
37 Correct 61 ms 13012 KB Output is correct
38 Correct 49 ms 12884 KB Output is correct
39 Correct 66 ms 12864 KB Output is correct
40 Correct 57 ms 13012 KB Output is correct
41 Correct 65 ms 13632 KB Output is correct
42 Correct 67 ms 13508 KB Output is correct
43 Correct 66 ms 13640 KB Output is correct
44 Correct 63 ms 13524 KB Output is correct
45 Correct 59 ms 13628 KB Output is correct
46 Correct 59 ms 13772 KB Output is correct
47 Correct 52 ms 12876 KB Output is correct
48 Correct 76 ms 12944 KB Output is correct
49 Correct 55 ms 12756 KB Output is correct
50 Correct 50 ms 12876 KB Output is correct
51 Correct 55 ms 11988 KB Output is correct
52 Correct 45 ms 12116 KB Output is correct
53 Correct 47 ms 12116 KB Output is correct
54 Correct 47 ms 12092 KB Output is correct
55 Correct 48 ms 11988 KB Output is correct
56 Correct 47 ms 12116 KB Output is correct
57 Correct 54 ms 12220 KB Output is correct
58 Correct 43 ms 12232 KB Output is correct
59 Correct 44 ms 11988 KB Output is correct
60 Correct 45 ms 11860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 11528 KB Output is correct
2 Correct 52 ms 12284 KB Output is correct
3 Correct 2 ms 1536 KB Output is correct
4 Correct 37 ms 11384 KB Output is correct
5 Correct 65 ms 13700 KB Output is correct
6 Correct 64 ms 13828 KB Output is correct
7 Correct 47 ms 12944 KB Output is correct
8 Correct 51 ms 12876 KB Output is correct
9 Correct 58 ms 14224 KB Output is correct
10 Correct 63 ms 14340 KB Output is correct
11 Correct 60 ms 14284 KB Output is correct
12 Correct 57 ms 14332 KB Output is correct
13 Correct 57 ms 14332 KB Output is correct
14 Correct 57 ms 14344 KB Output is correct
15 Correct 63 ms 14284 KB Output is correct
16 Correct 59 ms 14156 KB Output is correct
17 Correct 57 ms 13908 KB Output is correct
18 Correct 57 ms 13920 KB Output is correct
19 Correct 55 ms 13964 KB Output is correct
20 Correct 56 ms 13964 KB Output is correct
21 Correct 56 ms 13960 KB Output is correct
22 Correct 56 ms 13972 KB Output is correct
23 Correct 47 ms 11824 KB Output is correct
24 Correct 43 ms 11856 KB Output is correct
25 Correct 47 ms 12416 KB Output is correct
26 Correct 50 ms 12232 KB Output is correct
27 Correct 54 ms 13124 KB Output is correct
28 Correct 53 ms 13012 KB Output is correct
29 Correct 56 ms 13260 KB Output is correct
30 Correct 54 ms 13144 KB Output is correct
31 Correct 45 ms 11880 KB Output is correct
32 Correct 52 ms 11880 KB Output is correct
33 Correct 47 ms 12288 KB Output is correct
34 Correct 52 ms 12416 KB Output is correct
35 Correct 53 ms 12892 KB Output is correct
36 Correct 59 ms 13256 KB Output is correct
37 Correct 53 ms 12884 KB Output is correct
38 Correct 55 ms 13012 KB Output is correct
39 Correct 63 ms 12744 KB Output is correct
40 Correct 59 ms 12884 KB Output is correct
41 Correct 59 ms 13644 KB Output is correct
42 Correct 57 ms 13396 KB Output is correct
43 Correct 56 ms 13648 KB Output is correct
44 Correct 69 ms 13628 KB Output is correct
45 Correct 56 ms 13516 KB Output is correct
46 Correct 63 ms 13688 KB Output is correct
47 Correct 51 ms 12844 KB Output is correct
48 Correct 51 ms 12820 KB Output is correct
49 Correct 57 ms 12816 KB Output is correct
50 Correct 59 ms 12768 KB Output is correct
51 Correct 53 ms 12216 KB Output is correct
52 Correct 53 ms 12208 KB Output is correct
53 Correct 68 ms 11956 KB Output is correct
54 Correct 68 ms 12196 KB Output is correct
55 Correct 54 ms 12200 KB Output is correct
56 Correct 55 ms 12108 KB Output is correct
57 Correct 55 ms 12116 KB Output is correct
58 Correct 46 ms 12116 KB Output is correct
59 Correct 54 ms 12120 KB Output is correct
60 Correct 63 ms 11980 KB Output is correct