답안 #513327

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
513327 2022-01-17T05:26:42 Z wiwiho 길고양이 (JOI20_stray) C++14
76 / 100
61 ms 17380 KB
#include "Anthony.h"
#include <bits/stdc++.h>

#define mp make_pair
#define F first
#define S second
#define iter(a) a.begin(), a.end()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(iter(a), greater<>())
#define eb emplace_back
#define printv(a, b) { \
    for(auto pv : a) b << pv << " "; \
    b << "\n"; \
}

using namespace std;

using pii = pair<int, int>;

namespace {

    vector<int> magic;
    vector<vector<pii>> g;
    vector<int> ans;

}  // namespace

void dfs(int now, int p, int top, int len){
    int cnt = 0;
    for(pii i : g[now]){
        if(i.F == p) continue;
        cnt++;
    }
    int nxt = !top;
    if(cnt == 1){
        if(len == -1){
            if(top == 0) len = 0;
            else len = 1;
        }
        len++;
        //cerr << "two " << now << " " << len << "\n";
        nxt = magic[len % 6];
    }
    else len = -1;

    for(pii i : g[now]){
        if(i.F == p) continue;
        ans[i.S] = nxt;
        dfs(i.F, now, nxt, len);
    }
}

vector<int> Mark(int n, int m, int A, int B,
                      vector<int> U, vector<int> V) {

    magic = {0, 1, 0, 0, 1, 1};

    ans.resize(m);

    g.resize(n);
    for(int i = 0; i < m; i++){
        int u = U[i], v = V[i];
        g[u].eb(mp(v, i));
        g[v].eb(mp(u, i));
    }

    dfs(0, 0, 1, -1);
    //printv(ans, cerr);

    return ans;
}
#include "Catherine.h"
#include <bits/stdc++.h>

#define mp make_pair
#define F first
#define S second
#define iter(a) a.begin(), a.end()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(iter(a), greater<>())
#define eb emplace_back
#define printv(a, b) { \
    for(auto pv : a) b << pv << " "; \
    b << "\n"; \
}

using namespace std;

namespace {

int A, B;
int lst = -1;
vector<int> magic;
deque<int> tmp;

}  // namespace

void Init(int A, int B) {
    ::A = A;
    ::B = B;
    magic = {0, 1, 0, 0, 1, 1};
}

bool check(){
    while(tmp.size() > 6) tmp.pop_front();
    if(tmp.size() < 6) return false;

    for(int i = 0; i < 6; i++){
        bool ok = true;
        for(int j = 0; j < 6; j++){
            if(tmp[j] != magic[(i + j) % 6]) ok = false;
        }
        if(ok) return true;
    }
    return false;
}

int Move(vector<int> y) {
    
    if(lst != -1) y[lst]++;
    int deg = 0;
    for(int i : y) deg += i;

    if(deg >= 3){
        int r;
        for(int i = 0; i < 2; i++){
            if(y[i] != 1) continue;
            if(i == lst) r = -1;
            else r = lst = i;
        }
        tmp.clear();
        tmp.eb(lst);
        //cerr << "test " << r << "\n";
        return r;
    }

    //cerr << "check ";
    //printv(tmp, cerr);
    if(check()){
        tmp.clear();
        tmp.eb(lst);
        return -1;
    }

    int nxt = -1;
    if(lst != -1) y[lst]--;
    for(int i = 0; i < 2; i++){
        if(y[i]){
            nxt = i;
            //break;
        }
    }

    lst = nxt;
    tmp.eb(nxt);
    //cerr << nxt << "\n";

    return nxt;
}

Compilation message

Catherine.cpp: In function 'int Move(std::vector<int>)':
Catherine.cpp:54:13: warning: 'r' may be used uninitialized in this function [-Wmaybe-uninitialized]
   54 |         int r;
      |             ^
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 16004 KB Output is correct
2 Correct 0 ms 584 KB Output is correct
3 Correct 28 ms 14936 KB Output is correct
4 Correct 61 ms 17232 KB Output is correct
5 Correct 52 ms 17380 KB Output is correct
6 Correct 41 ms 15528 KB Output is correct
7 Incorrect 36 ms 15412 KB Wrong Answer [6]
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 16004 KB Output is correct
2 Correct 0 ms 584 KB Output is correct
3 Correct 28 ms 14936 KB Output is correct
4 Correct 61 ms 17232 KB Output is correct
5 Correct 52 ms 17380 KB Output is correct
6 Correct 41 ms 15528 KB Output is correct
7 Incorrect 36 ms 15412 KB Wrong Answer [6]
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 42 ms 13592 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 40 ms 12864 KB Output is correct
4 Correct 54 ms 15180 KB Output is correct
5 Correct 60 ms 15248 KB Output is correct
6 Correct 38 ms 13236 KB Output is correct
7 Incorrect 33 ms 13264 KB Wrong Answer [6]
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 42 ms 13592 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 40 ms 12864 KB Output is correct
4 Correct 54 ms 15180 KB Output is correct
5 Correct 60 ms 15248 KB Output is correct
6 Correct 38 ms 13236 KB Output is correct
7 Incorrect 33 ms 13264 KB Wrong Answer [6]
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 772 KB Output is correct
2 Correct 1 ms 548 KB Output is correct
3 Correct 2 ms 840 KB Output is correct
4 Correct 3 ms 928 KB Output is correct
5 Correct 2 ms 876 KB Output is correct
6 Correct 2 ms 832 KB Output is correct
7 Correct 2 ms 888 KB Output is correct
8 Correct 2 ms 848 KB Output is correct
9 Correct 2 ms 844 KB Output is correct
10 Correct 2 ms 876 KB Output is correct
11 Correct 2 ms 884 KB Output is correct
12 Correct 2 ms 836 KB Output is correct
13 Correct 2 ms 848 KB Output is correct
14 Correct 2 ms 876 KB Output is correct
15 Correct 2 ms 876 KB Output is correct
16 Correct 2 ms 884 KB Output is correct
17 Correct 2 ms 876 KB Output is correct
18 Correct 2 ms 876 KB Output is correct
19 Correct 2 ms 748 KB Output is correct
20 Correct 2 ms 836 KB Output is correct
21 Correct 2 ms 824 KB Output is correct
22 Correct 2 ms 836 KB Output is correct
23 Correct 2 ms 876 KB Output is correct
24 Correct 2 ms 816 KB Output is correct
25 Correct 2 ms 880 KB Output is correct
26 Correct 2 ms 876 KB Output is correct
27 Correct 2 ms 932 KB Output is correct
28 Correct 2 ms 812 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 41 ms 11344 KB Output is correct
2 Correct 43 ms 12460 KB Output is correct
3 Correct 1 ms 440 KB Output is correct
4 Correct 29 ms 11060 KB Output is correct
5 Correct 49 ms 13652 KB Output is correct
6 Correct 41 ms 13756 KB Output is correct
7 Correct 32 ms 12788 KB Output is correct
8 Correct 37 ms 12968 KB Output is correct
9 Correct 53 ms 13940 KB Output is correct
10 Correct 41 ms 14088 KB Output is correct
11 Correct 39 ms 13920 KB Output is correct
12 Correct 46 ms 13928 KB Output is correct
13 Correct 41 ms 14016 KB Output is correct
14 Correct 41 ms 13920 KB Output is correct
15 Correct 39 ms 13984 KB Output is correct
16 Correct 54 ms 13940 KB Output is correct
17 Correct 44 ms 13660 KB Output is correct
18 Correct 38 ms 13620 KB Output is correct
19 Correct 38 ms 13588 KB Output is correct
20 Correct 38 ms 13676 KB Output is correct
21 Correct 40 ms 13608 KB Output is correct
22 Correct 43 ms 13688 KB Output is correct
23 Correct 38 ms 11764 KB Output is correct
24 Correct 32 ms 11572 KB Output is correct
25 Correct 35 ms 11980 KB Output is correct
26 Correct 47 ms 11892 KB Output is correct
27 Correct 37 ms 12760 KB Output is correct
28 Correct 42 ms 12768 KB Output is correct
29 Correct 48 ms 12808 KB Output is correct
30 Correct 35 ms 12740 KB Output is correct
31 Correct 30 ms 11624 KB Output is correct
32 Correct 31 ms 11704 KB Output is correct
33 Correct 37 ms 11956 KB Output is correct
34 Correct 44 ms 11928 KB Output is correct
35 Correct 39 ms 12600 KB Output is correct
36 Correct 45 ms 12712 KB Output is correct
37 Correct 44 ms 12716 KB Output is correct
38 Correct 39 ms 12604 KB Output is correct
39 Correct 41 ms 12600 KB Output is correct
40 Correct 40 ms 12708 KB Output is correct
41 Correct 46 ms 13224 KB Output is correct
42 Correct 45 ms 13208 KB Output is correct
43 Correct 46 ms 13268 KB Output is correct
44 Correct 44 ms 13236 KB Output is correct
45 Correct 45 ms 13224 KB Output is correct
46 Correct 44 ms 13304 KB Output is correct
47 Correct 36 ms 12652 KB Output is correct
48 Correct 40 ms 12476 KB Output is correct
49 Correct 44 ms 12376 KB Output is correct
50 Correct 52 ms 12456 KB Output is correct
51 Correct 37 ms 11732 KB Output is correct
52 Correct 47 ms 11860 KB Output is correct
53 Correct 42 ms 11812 KB Output is correct
54 Correct 34 ms 11924 KB Output is correct
55 Correct 40 ms 11800 KB Output is correct
56 Correct 44 ms 11820 KB Output is correct
57 Correct 46 ms 11732 KB Output is correct
58 Correct 34 ms 11704 KB Output is correct
59 Correct 34 ms 11840 KB Output is correct
60 Correct 44 ms 11728 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 11244 KB Output is correct
2 Correct 44 ms 12308 KB Output is correct
3 Correct 1 ms 556 KB Output is correct
4 Correct 30 ms 11028 KB Output is correct
5 Correct 55 ms 13676 KB Output is correct
6 Correct 52 ms 13612 KB Output is correct
7 Incorrect 47 ms 12768 KB Wrong Answer [6]
8 Halted 0 ms 0 KB -