Submission #259462

# Submission time Handle Problem Language Result Execution time Memory
259462 2020-08-07T21:39:11 Z Bruteforceman Stray Cat (JOI20_stray) C++17
0 / 100
61 ms 16832 KB
#include "bits/stdc++.h"
#include "Anthony.h"
using namespace std;

namespace {
  const int maxn = 2e4 + 10;
  const int t[] = {1, 0, 0, 1, 1, 0};
  const int len = 6;
  int l[maxn], r[maxn];
  vector <int> g[maxn];
  int mark[maxn];

  void dfs(int x, int par, int idx) {
    int child = 0;
    for(auto e : g[x]) {
      if(e != par) {
        child += 1; 
      }
    }
    if(child == 1 && idx == -1) {
      for(idx = 0; idx < len; idx++) {
        if(t[idx] == mark[x]) {
          break;
        }
      }
    }
    for(auto e : g[x]) {
      int i = l[e] ^ r[e] ^ x; 
      if(e != par) {
        if(child == 1) {
          mark[e] = t[(idx + 1) % len];
          dfs(i, e, (idx + 1) % len);
        } else {
          mark[e] = mark[par] ^ 1;
          dfs(i, e, -1);
        }
      }
    }
  }
}  // namespace

std::vector<int> Mark(int N, int M, int A, int B,
                      std::vector<int> U, std::vector<int> V) {
  std::vector<int> X(M);
  for (int i = 0; i < N; i++) g[i].clear();
  for (int i = 0; i < M; ++i) {
    l[i] = U[i];
    r[i] = V[i];
    g[l[i]].push_back(i);
    g[r[i]].push_back(i);
  }
  mark[M] = 0;
  dfs(0, M, -1);
  for(int i = 0; i < M; i++) X[i] = mark[i];
  for(int i = 0; i < M; i++) {
    // cout << U[i] << ' ' << V[i] << ' ' << X[i] << endl;
  }
  return X;
}
#include "bits/stdc++.h"
#include "Catherine.h"
using namespace std;

namespace {
const int len = 6;
const int t[len] = {1, 0, 0, 1, 1, 0};
int arr[len];
int idx = -1;

int A, B;
int variable_example = 0;
vector <int> unpack(vector <int> y) {
  vector <int> v;
  for(int i = 0; i < y.size(); i++) {
    while(y[i]--) v.push_back(i);
  }
  return v;
}
bool check() {
  for(int i = 0; i < len; i++) {
    bool bad = false;
    for(int j = 0; j < len; j++) {
      if(t[(i + j) % len] != arr[j]) bad = true;
    }
    if(not bad) return true;
  }
  return false;
}
int last = -1;
}  // namespace

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

int Move(std::vector<int> y) {
  ++variable_example;
  vector <int> v = unpack(y);
  if(variable_example == 1 && v.size() == 2) {
    idx = 1; 
    arr[idx - 1] = v[0];
    arr[idx] = v[1];
    return last = v[1];
  }
  if(idx != -1) {
    if(v.size() == 1) {
      arr[idx + 1] = v[0];
      idx += 1;
      if(idx == len - 1) {
        idx = -1;
        if(check()) return -1;
        else return last = v[0];
      } else {
        return last = v[0];
      }
    } else {
      idx = -1;
      if(y[0] == 0 || y[1] == 0) return -1;
      else return last = last ^ 1;
    }
  }
  if(v.size() == 1) return last = v[0];
  else return last = last ^ 1;
}

Compilation message

Catherine.cpp: In function 'std::vector<int> {anonymous}::unpack(std::vector<int>)':
Catherine.cpp:15:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0; i < y.size(); i++) {
                  ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 61 ms 16832 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 61 ms 16832 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 52 ms 14284 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 52 ms 14284 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1792 KB Output is correct
2 Incorrect 1 ms 1536 KB Wrong Answer [3]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 53 ms 11932 KB Output is correct
2 Correct 52 ms 13236 KB Output is correct
3 Correct 1 ms 1536 KB Output is correct
4 Incorrect 36 ms 11688 KB Wrong Answer [3]
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 43 ms 12068 KB Output is correct
2 Correct 46 ms 13120 KB Output is correct
3 Correct 1 ms 1536 KB Output is correct
4 Incorrect 42 ms 11564 KB Wrong Answer [3]
5 Halted 0 ms 0 KB -