제출 #764039

#제출 시각아이디문제언어결과실행 시간메모리
764039boyliguanhan길고양이 (JOI20_stray)C++17
100 / 100
41 ms16604 KiB
#include "Anthony.h"
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
vector<int> X, paint{0, 1, 0, 0, 1, 1};
vector<pair<int, int>> adj[20000];
int vis[20000];
void m1(int n = 0, int pi = -1, int depth = 0) {
    if (pi+1) X[pi] = paint[depth];
    for (auto i : adj[n])
        if (i.S != pi) {
            if (adj[n].size() == 2) 
                m1(i.F, i.S, (depth + 1) % 6);
            else
                m1(i.F, i.S, 1 ^ paint[depth]);
        }
}
void m2() {
    queue<int> q;
    q.push(0);
    vis[0] = 1;
    while (q.size()) {
        int n = q.front();
        q.pop();
        for (auto i : adj[n])
            if (!vis[i.F]) {
                X[i.S] = (vis[n] - 1) % 3;
                vis[i.F] = vis[n] + 1;
                q.push(i.F); 
            } else
                X[i.S] = (vis[i.F] - 1) % 3;
    }
}
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], i});
        adj[V[i]].push_back({U[i], i});
    }
    X.resize(M);
    if (B) m1();
    else m2();
    return X;
}
#include "Catherine.h"
#include <bits/stdc++.h>
using namespace std;
int a, b, last;
bool up;
vector<int> seen;
vector<vector<int>> poss = {{1, 1, 0, 0, 1},{1, 0, 0, 1, 0},{0, 0, 1, 0, 1},{0, 1, 0, 1, 1},{1, 0, 1, 1, 0},{0, 1, 1, 0, 0},};
int move_tree(vector<int> y) {
    vector<int> y2 = y;
    if (last+1) y2[last]++;
    int cnt = 0;
    for(auto i: y2)
        cnt+=i;
    if (cnt != 2)
        up = 1;
    if (up) {
        if (cnt == 1){
            if (last==-1)
                for(int i = 0; i < a; i++)
                    if (y[i])
                        return last = i;
            return -1;
        } else if (cnt == 2) {
            for(int i = 0; i < a; i++)
                if (y[i])
                    return last = i;
        } else {
            for(int i = 0; i < a; i++)
                if (y2[i] == 1) {
                    if (!y[i])
                        return -1;
                    return last = i;
                }
        }
    } else{
        if (last+1){
            for(int i = 0; i < a; i++)
                if (y[i]) {
                    seen.push_back(i);
                    if (seen.size() < 5)
                        return last = i;
                    else {
                        up = 1;
                        for (vector<int> v : poss)
                            if (v == seen)
                                return last = i;
                        return -1;
                    }
                }
        }else{
            for(int i = 0; i < a; i++) 
                if (y[i]) {
                    seen.push_back(i);
                    y[i]--;
                    for(int j = 0; j < a; j++)
                        if (y[j]) {
                            seen.push_back(j);
                            return last = j;
                        }
                }
        }
    }
}
int move_graph(vector<int> y) {
    if (last+1) y[last]++;
    for(int i = 0; i < 3; i++)
        if (y[i] && y[(i + 1) % 3])
            return last = i;
    for(int i = 0; i < 3; i++)
        if (y[i])
            return last = i;
}   
void Init(int A, int B) {
    a = A;
    b = B;
    up = false;
    last = -1;
}
int Move(vector<int> y) {
    if (b)
        return move_tree(y);
    return move_graph(y);
}

컴파일 시 표준 에러 (stderr) 메시지

Catherine.cpp: In function 'int move_tree(std::vector<int>)':
Catherine.cpp:9:22: warning: control reaches end of non-void function [-Wreturn-type]
    9 |     vector<int> y2 = y;
      |                      ^
Catherine.cpp: In function 'int move_graph(std::vector<int>)':
Catherine.cpp:72:1: warning: control reaches end of non-void function [-Wreturn-type]
   72 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...