Submission #799489

# Submission time Handle Problem Language Result Execution time Memory
799489 2023-07-31T15:08:56 Z burythelightdeepwithin Stray Cat (JOI20_stray) C++14
0 / 100
28 ms 16848 KB
#include <bits/stdc++.h>
#include "Anthony.h"

using namespace std;

vector <pair <int, int> > adj[20003], adj_dfs[20003];
vector <int> plan;
int vs[20003], sz[20003], start = 1;
int route[6] = {0, 1, 0, 0, 1, 1};
queue <int> q;
vector <int> leaf;

void bfs(){
    while(!q.empty()){
        int u = q.front();
        vs[u] = 1;
        q.pop();
        for (auto e: adj[u]){
            int v = e.first, id = e.second;
            if (!vs[v]){
                q.push(v);
                vs[v] = 1;
                adj_dfs[u].push_back({v, id});
                //adj_dfs[v].push_back({u, id});
                sz[u]++;
            }
        }
    }
}

void dfs(int u, int mark, int last){
    vs[u] = 1;
    if (sz[u] > 1){
        mark = 0;
        start = (last^1);
    }
    for (auto e: adj_dfs[u]){
        int v = e.first, id = e.second;
        if (!vs[v]){
            plan[id] = (route[mark]^start);
            dfs(v, (mark+1)%6, plan[id]);
        }
    }
}

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});
        plan.push_back(-1);
    }
    q.push(0);
    bfs();
    for (int i = 0; i < N; i++){
        vs[i] = 0;
    }
    dfs(0, 0, 0);
    for (int i = 0; i < M; i++){
        if (plan[i] == -1){
            plan[i] = 2;
        }
    }
    return plan;
}
#include <bits/stdc++.h>
#include "Catherine.h"

using namespace std;

int first = -1, last = -1, cnt = 0, one, zero;

void Init(int A, int B){

}

int Move(vector <int> y){
    if (cnt == 0){
        if (y[0] == 0){
            if (y[1] == 1){
                cnt = 3;
            } else if (y[1] == 2) {
                cnt++;
            }
            last = 1;
            one++;
            first = last;
            return 1;
        } else if (y[1] == 0){
            if (y[0] == 1){
                cnt = 3;
            } else if (y[0] == 2) {
                cnt++;
            }
            zero++;
            last = 0;
            first = last;
            return 0;
        }
        if (y[0] > y[1]){
            last = 1;
            one++;
            return 1;
        } else if (y[0] < y[1]){
            last = 0;
            zero++;
            return 0;
        } else {
            last = 0;
            zero++;
            return 0;
        }
    }
    if (cnt == 1){
        if (y[0] == 0 && y[1] == 0){
            cnt = 3;
            return -1;
        }
        if (last == 0){
            if (y[1] == 1){
                cnt++;
                last = 1;
                one++;
                return 1;
            } else if (y[0] == 1){
                cnt++;
                last = 0;
                zero++;
                return 0;
            }
        } else {
            if (y[1] == 1){
                cnt++;
                last = 1;
                one++;
                return 1;
            } else if (y[0] == 1){
                cnt++;
                last = 0;
                zero++;
                return 0;
            }
        }
    }
    if (cnt == 2){
        if (y[0] == 0 && y[1] == 0){
            cnt = 3;
            return -1;
        }
        if (zero == 2){
            if (y[1] == 1){
                cnt++;  
                return -1;
            } else if (y[0] == 1){
                cnt++;
                return 0;
            }
        } else if (one == 2){
            if (y[0] == 1){
                cnt++;
                return 0;
            } else if (y[1] == 1){
                cnt++;
                return -1;
            }
        } else {
            if (first == 0){
                if (y[1] == 1){
                    cnt++;
                    return -1;
                } else if (y[0] == 1){
                    cnt++;
                    return 0;
                }
            } else {
                if (y[0] == 1){
                    cnt++;
                    return -1;
                } else if (y[1] == 1){
                    cnt++;
                    return 1;
                }
            }
        }
    }
    if (y[0] == 1){
        return 0;
    } else {
        return 1;
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 16848 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 16848 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 28 ms 14600 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 28 ms 14600 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 1796 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 12268 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 12276 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -