Submission #291499

# Submission time Handle Problem Language Result Execution time Memory
291499 2020-09-05T12:14:00 Z zoooma13 Stray Cat (JOI20_stray) C++14
0 / 100
59 ms 28788 KB
#include <bits/stdc++.h>
#include "Anthony.h"
using namespace std;

#define all(v) v.begin() ,v.end()

namespace{
    vector <vector<pair<int ,int>>> adj;
    vector <int> enc ,seq = {0,0,1,0,1,1};
    void dfs(int u ,int d=0 ,bool bef=0){
        for(auto&e : adj[u]){
            adj[e.first].erase(find(all(adj[e.first]) ,make_pair(u ,e.second)));
            if(adj[u].size() > 1){
                enc[e.second] = bef^1;
                dfs(e.first ,0 ,enc[e.second]);
            }else{
                if(d == 0) d = (bef? 0 : 2);
                enc[e.second] = seq[d%6];
                dfs(e.first ,d+1 ,enc[e.second]);
            }
        }
    }
}

vector <int> Mark(int N, int M, int A, int B,vector<int> U,vector<int> V){
    assert(M == N-1);
    adj.resize(N);
    enc.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);
    return enc;
}
#include <bits/stdc++.h>
#include "Catherine.h"
using namespace std;

namespace{
    int lst;
    vector <int> bef ,seq = {0,0,1,0,1,1};
}

void Init(int A, int B) {  }

int Move(vector<int> y){
    if(y[0] < y[1] && y[0]){
        bef.clear();
        return lst = 0;
    }
    if(y[1] < y[0] && y[1]){
        bef.clear();
        return lst = 1;
    }
    assert(y[0] == y[1] && y[0] <= 1);

    if(bef.size() == 6){
        for(int t=0; t<6; t++){
            if(bef == seq)
                return -1;
            seq.insert(seq.begin() ,seq.back()) ,seq.pop_back();
        }
    }

    if(!y[0] && !y[1]){
        bef.clear();
        return -1;
    }

    bef.push_back(lst^=1);
    return lst;
}
# Verdict Execution time Memory Grader output
1 Runtime error 59 ms 28788 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 59 ms 28788 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 54 ms 24308 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 54 ms 24308 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 1420 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 49 ms 20048 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 52 ms 20176 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -