답안 #939984

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
939984 2024-03-07T03:22:43 Z guagua0407 길고양이 (JOI20_stray) C++17
85 / 100
41 ms 16732 KB
#include "Anthony.h"
#include <vector>
#include<bits/stdc++.h>

namespace {

using namespace std;
#define f first
#define s second
int A,B;
const int mxn=2e4+5;
vector<pair<int,int>> adj[mxn];
vector<int> ans;
vector<int> ch={0,0,1,0,1,1};

void dfs(int v,int p=-1,int c=0,int cur=-1){
    for(auto u:adj[v]){
        if(u.f==p) continue;
        if(v!=0 and (int)adj[v].size()==2){
            if(cur==-1){
                if(c==0) cur=2;
                else cur=0;
            }
            ans[u.s]=ch[cur];
            dfs(u.f,v,ans[u.s],(cur+1)%6);
        }
        else{
            ans[u.s]=(c+1)%2;
            dfs(u.f,v,ans[u.s],-1);
        }
    }
}

}  // namespace

std::vector<int> Mark(int N, int M, int A, int B,std::vector<int> U, std::vector<int> V) {
    ::A = A;
    ::B = B;
    ans.resize(M);
    for(int i=0;i<M;i++){
        adj[U[i]].push_back({V[i],i});
        adj[V[i]].push_back({U[i],i});
    }
    dfs(0);
    //ans=vector<int>(M,0);
    return ans;
}
#include "Catherine.h"
#include <vector>
#include<bits/stdc++.h>
namespace {
using namespace std;
#define all(x) x.begin(),x.end()
int A, B;
int variable_example = 0;
int prv=-1;
map<vector<int>,int> down,up;
vector<int> ch={0,0,1,0,1,1};
bool on=false;
bool dir=false;
vector<int> cur;

}  // namespace

void Init(int A, int B) {
    ::A = A;
    ::B = B;
    for(int i=0;i<6;i++){
        vector<int> tmp;
        for(int j=0;j<5;j++){
            tmp.push_back(ch[(i+j)%6]);
        }
        down[tmp]++;
    }
    reverse(all(ch));
    for(int i=0;i<6;i++){
        vector<int> tmp;
        for(int j=0;j<5;j++){
            tmp.push_back(ch[(i+j)%6]);
        }
        up[tmp]++;
    }
}

int Move(std::vector<int> y) {
    if(prv!=-1) y[prv]++;
    if((y[0]>1 and y[1]==1) or (y[1]>1 and y[0]==1)){
        dir=true;
        if(y[0]>1){
            if(prv==1){
                prv=1;
                return -1;
            }
            else{
                prv=1;
                return 1;
            }
        }
        else{
            if(prv==0){
                prv=0;
                return -1;
            }
            else{
                prv=0;
                return 0;
            }
        }
    }
    if(y[0]+y[1]==1){
        dir=true;
        if(y[0]==1){
            if(prv==-1){
                prv=0;
                return 0;
            }
            else{
                prv=0;
                return -1;
            }
        }
        else{
            if(prv==-1){
                prv=1;
                return 1;
            }
            else{
                prv=1;
                return -1;
            }
        }
    }
    if(dir==true){
        y[prv]--;
        if(y[0]>0){
            prv=0;
        }
        else{
            prv=1;
        }
        return prv;
    }
    if(on==true){
        cur.push_back(prv);
        if((int)cur.size()==4){
            y[prv]--;
            if(y[0]>0) cur.push_back(0);
            else cur.push_back(1);
            y[prv]++;
            if(up.find(cur)!=up.end()){
                dir=true;
                prv=cur.back();
                return prv;
            }
            else{
                dir=true;
                return -1;
            }
        }
        else{
            y[prv]--;
            if(y[0]>0){
                prv=0;
                return prv;
            }
            else{
                prv=1;
                return prv;
            }
        }
    }
    else{
        on=true;
        vector<int> edge;
        for(int i=0;i<2;i++){
            for(int j=0;j<y[i];j++) edge.push_back(i);
        }
        cur.push_back(edge[0]);
        prv=edge[1];
        return prv;
    }
}

Compilation message

Catherine.cpp:8:5: warning: '{anonymous}::variable_example' defined but not used [-Wunused-variable]
    8 | int variable_example = 0;
      |     ^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 28 ms 16732 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 28 ms 16732 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 14416 KB Output is correct
2 Correct 1 ms 1312 KB Output is correct
3 Correct 27 ms 13160 KB Output is correct
4 Correct 41 ms 16212 KB Output is correct
5 Incorrect 32 ms 15868 KB Wrong Answer [6]
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 14416 KB Output is correct
2 Correct 1 ms 1312 KB Output is correct
3 Correct 27 ms 13160 KB Output is correct
4 Correct 41 ms 16212 KB Output is correct
5 Incorrect 32 ms 15868 KB Wrong Answer [6]
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1576 KB Output is correct
2 Correct 1 ms 1300 KB Output is correct
3 Correct 2 ms 1616 KB Output is correct
4 Correct 2 ms 1572 KB Output is correct
5 Correct 2 ms 1564 KB Output is correct
6 Correct 2 ms 1564 KB Output is correct
7 Correct 2 ms 1556 KB Output is correct
8 Correct 2 ms 1572 KB Output is correct
9 Correct 2 ms 1564 KB Output is correct
10 Correct 2 ms 1572 KB Output is correct
11 Correct 2 ms 1568 KB Output is correct
12 Correct 2 ms 1552 KB Output is correct
13 Correct 2 ms 1556 KB Output is correct
14 Correct 2 ms 1564 KB Output is correct
15 Correct 2 ms 1564 KB Output is correct
16 Correct 2 ms 1576 KB Output is correct
17 Correct 2 ms 1572 KB Output is correct
18 Correct 2 ms 1564 KB Output is correct
19 Correct 2 ms 1568 KB Output is correct
20 Correct 2 ms 1604 KB Output is correct
21 Correct 2 ms 1556 KB Output is correct
22 Correct 2 ms 1656 KB Output is correct
23 Correct 2 ms 1556 KB Output is correct
24 Correct 2 ms 1564 KB Output is correct
25 Correct 1 ms 1572 KB Output is correct
26 Correct 2 ms 1568 KB Output is correct
27 Correct 2 ms 1572 KB Output is correct
28 Correct 2 ms 1564 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 11828 KB Output is correct
2 Correct 27 ms 13196 KB Output is correct
3 Correct 1 ms 1300 KB Output is correct
4 Correct 20 ms 12076 KB Output is correct
5 Correct 31 ms 14628 KB Output is correct
6 Correct 40 ms 14420 KB Output is correct
7 Correct 26 ms 13480 KB Output is correct
8 Correct 27 ms 13376 KB Output is correct
9 Correct 31 ms 14376 KB Output is correct
10 Correct 37 ms 14724 KB Output is correct
11 Correct 31 ms 14420 KB Output is correct
12 Correct 32 ms 14408 KB Output is correct
13 Correct 31 ms 14408 KB Output is correct
14 Correct 33 ms 14404 KB Output is correct
15 Correct 31 ms 14400 KB Output is correct
16 Correct 37 ms 14540 KB Output is correct
17 Correct 28 ms 14076 KB Output is correct
18 Correct 28 ms 14160 KB Output is correct
19 Correct 28 ms 14352 KB Output is correct
20 Correct 30 ms 14164 KB Output is correct
21 Correct 32 ms 14152 KB Output is correct
22 Correct 37 ms 14180 KB Output is correct
23 Correct 24 ms 11868 KB Output is correct
24 Correct 26 ms 11820 KB Output is correct
25 Correct 29 ms 12360 KB Output is correct
26 Correct 25 ms 12368 KB Output is correct
27 Correct 32 ms 13216 KB Output is correct
28 Correct 30 ms 13040 KB Output is correct
29 Correct 26 ms 13100 KB Output is correct
30 Correct 27 ms 13396 KB Output is correct
31 Correct 26 ms 11852 KB Output is correct
32 Correct 28 ms 12244 KB Output is correct
33 Correct 29 ms 12152 KB Output is correct
34 Correct 25 ms 12312 KB Output is correct
35 Correct 27 ms 12880 KB Output is correct
36 Correct 28 ms 12984 KB Output is correct
37 Correct 31 ms 12888 KB Output is correct
38 Correct 26 ms 12848 KB Output is correct
39 Correct 27 ms 12840 KB Output is correct
40 Correct 37 ms 12972 KB Output is correct
41 Correct 28 ms 13644 KB Output is correct
42 Correct 31 ms 13648 KB Output is correct
43 Correct 30 ms 13784 KB Output is correct
44 Correct 31 ms 13824 KB Output is correct
45 Correct 30 ms 13640 KB Output is correct
46 Correct 31 ms 13964 KB Output is correct
47 Correct 26 ms 12876 KB Output is correct
48 Correct 27 ms 12876 KB Output is correct
49 Correct 28 ms 12620 KB Output is correct
50 Correct 27 ms 12968 KB Output is correct
51 Correct 24 ms 11848 KB Output is correct
52 Correct 33 ms 12188 KB Output is correct
53 Correct 26 ms 11848 KB Output is correct
54 Correct 25 ms 11852 KB Output is correct
55 Correct 28 ms 11868 KB Output is correct
56 Correct 31 ms 11804 KB Output is correct
57 Correct 24 ms 12100 KB Output is correct
58 Correct 25 ms 11932 KB Output is correct
59 Correct 30 ms 11728 KB Output is correct
60 Correct 26 ms 11848 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 11848 KB Output is correct
2 Correct 28 ms 12872 KB Output is correct
3 Correct 1 ms 1296 KB Output is correct
4 Correct 20 ms 11584 KB Output is correct
5 Correct 37 ms 14328 KB Output is correct
6 Correct 39 ms 14484 KB Output is correct
7 Correct 27 ms 13404 KB Output is correct
8 Correct 27 ms 13396 KB Output is correct
9 Correct 31 ms 14416 KB Output is correct
10 Correct 31 ms 14416 KB Output is correct
11 Correct 35 ms 14396 KB Output is correct
12 Correct 30 ms 14360 KB Output is correct
13 Correct 35 ms 14560 KB Output is correct
14 Correct 31 ms 14464 KB Output is correct
15 Correct 31 ms 14384 KB Output is correct
16 Correct 31 ms 14364 KB Output is correct
17 Correct 28 ms 14432 KB Output is correct
18 Correct 32 ms 14392 KB Output is correct
19 Correct 27 ms 14164 KB Output is correct
20 Correct 30 ms 13964 KB Output is correct
21 Correct 31 ms 14116 KB Output is correct
22 Correct 30 ms 14156 KB Output is correct
23 Correct 25 ms 11900 KB Output is correct
24 Correct 26 ms 11848 KB Output is correct
25 Correct 25 ms 12368 KB Output is correct
26 Correct 25 ms 12360 KB Output is correct
27 Correct 31 ms 13156 KB Output is correct
28 Correct 28 ms 13000 KB Output is correct
29 Correct 26 ms 13204 KB Output is correct
30 Correct 27 ms 13368 KB Output is correct
31 Correct 24 ms 11820 KB Output is correct
32 Correct 25 ms 11856 KB Output is correct
33 Correct 28 ms 12372 KB Output is correct
34 Correct 25 ms 12224 KB Output is correct
35 Correct 26 ms 13208 KB Output is correct
36 Correct 26 ms 12884 KB Output is correct
37 Correct 26 ms 12884 KB Output is correct
38 Correct 27 ms 13148 KB Output is correct
39 Correct 27 ms 13092 KB Output is correct
40 Correct 26 ms 12892 KB Output is correct
41 Correct 28 ms 13664 KB Output is correct
42 Correct 31 ms 13640 KB Output is correct
43 Correct 27 ms 13576 KB Output is correct
44 Correct 36 ms 13828 KB Output is correct
45 Correct 34 ms 13636 KB Output is correct
46 Correct 28 ms 13736 KB Output is correct
47 Correct 28 ms 13004 KB Output is correct
48 Correct 26 ms 12892 KB Output is correct
49 Correct 26 ms 12524 KB Output is correct
50 Correct 27 ms 12888 KB Output is correct
51 Correct 28 ms 11928 KB Output is correct
52 Correct 27 ms 11792 KB Output is correct
53 Correct 25 ms 11860 KB Output is correct
54 Correct 25 ms 11996 KB Output is correct
55 Correct 25 ms 11860 KB Output is correct
56 Correct 24 ms 11900 KB Output is correct
57 Correct 31 ms 12072 KB Output is correct
58 Correct 25 ms 12264 KB Output is correct
59 Correct 25 ms 11804 KB Output is correct
60 Correct 24 ms 11836 KB Output is correct