Submission #674302

# Submission time Handle Problem Language Result Execution time Memory
674302 2022-12-23T16:45:52 Z null_awe Stray Cat (JOI20_stray) C++14
0 / 100
9 ms 3924 KB
#include "Anthony.h"
#include <vector>
#include <queue>
#include <assert.h>
using namespace std;

#define pii pair<int, int>

vector<int> Mark(int n, int m, int a, int b, vector<int> u, vector<int> v) {
  vector<vector<pii>> adj(n);
  for (int i = 0; i < m; ++i) adj[u[i]].push_back({v[i], i}), adj[v[i]].push_back({u[i], i});
  if (a == 2) {
    vector<int> color(m, -1), dist(n, -1), lp(n);
    for (int i = 0; i < n; ++i) lp[i] = i;
    queue<int> q; q.push(0), dist[0] = 0;
    while (q.size()) {
      int v = q.front(); q.pop();
      int label = dist[v] % 2;
      for (const auto& [u, i] : adj[v]) {
        if (color[i]) {
          if (adj[v].size() == 2) lp[i] = lp[u];
          continue;
        }
        color[i] = label;
        q.push(u), dist[u] = dist[v] + 1;
      }
    }
    vector<int> pat = {0, 1, 0, 0, 1, 1};
    for (int v = 0; v < n; ++v) {
      if (adj[v].size() != 2) continue;
      int p = lp[v];
      bool shift = dist[p] % 2;
      for (const auto& [u, i] : adj[v]) {
        if (dist[u] > dist[v]) {
          color[i] = pat[(dist[v] - dist[p] + shift) % 6];
        }
      }
    }
    return pat;
  }
  vector<int> color(m, -1), dist(n, -1);
  queue<int> q; q.push(0), dist[0] = 0;
  while (q.size()) {
    int v = q.front(); q.pop();
    int label = dist[v] % 3;
    for (const auto& [u, i] : adj[v]) {
      if (color[i]) continue;
      color[i] = label;
      if (dist[u] < 0) q.push(u), dist[u] = dist[v] + 1;
    }
  }
  for (int num : color) assert(num >= 0 && num < 3);
  return color;
}

#include "Catherine.h"
#include <vector>
#include <assert.h>
using namespace std;

int a;

void Init(int _a, int _b) {
  a = _a;
}

int prv = -1;
bool start = false;
vector<int> seen;

bool forwards() {
  assert(seen.size() == 5);
  vector<int> f1 = {0, 1, 0, 0, 1};
  vector<int> f2 = {1, 0, 0, 1, 1};
  vector<int> f3 = {0, 0, 1, 1, 0};
  vector<int> f4 = {0, 1, 1, 0, 1};
  vector<int> f5 = {1, 1, 0, 1, 0};
  vector<int> f6 = {1, 0, 1, 0, 0};
  return seen == f1 || seen == f2 || seen == f3 || seen == f4 || seen == f5 || seen == f6;
}

int Move(vector<int> y) {
  if (a == 2) {
    if (start) {
      if (y.size() == 1) {
        prv = y[0];
        return 0;
      }
      for (int i = 0; i < y.size(); ++i) {
        if (y[i] != prv) {
          prv = y[i];
          return i;
        }
      }
      // Shouldn't ever happen:
      assert(0);
      return 0;
    } else {
      if (y.size() > 1) {
        int sum = 0;
        for (int num : y) sum += num;
        if (sum == 0 || sum == y.size()) {
          start = true;
          return -1;
        }
        if (prv == -1 && y.size() == 2) {
          seen.push_back(y[0]), seen.push_back(y[1]);
          prv = y[1];
          return 1;
        }
        if (prv == -1) {
          int find = sum == 1;
          for (int i = 0; i < y.size(); ++i) {
            if (y[i] == find) {
              prv = y[i];
              start = true;
              return i;
            }
          }
          // Shouldn't ever happen:
          assert(0);
          return 0;
        }
        for (int i = 0; i < y.size(); ++i) {
          if (y[i] != prv) {
            prv = y[i];
            start = true;
            return i;
          }
        }
        // Shouldn't ever happen:
        assert(0);
        return 0;
      } else {
        if (y.size() == 0) {
          start = true;
          return -1;
        }
        seen.push_back(y[0]);
        if (seen.size() < 5) {
          prv = y[0];
          return 0;
        }
        start = true;
        if (forwards()) {
          prv = y[0];
          return 0;
        }
        return -1;
      }
      // Shouldn't ever happen:
      assert(0);
      return 0;
    }
  }
  vector<int> count(3);
  for (int num : y) ++count[num];
  if (max(count[0], max(count[1], count[2])) == y.size()) return 0;
  int find = !count[0] ? 1 : (!count[1] ? 2 : 0);
  for (int i = 0; i < y.size(); ++i) if (y[i] == find) return i;
  // Shouldn't ever happen:
  assert(0);
  return 0;
}

Compilation message

Anthony.cpp: In function 'std::vector<int> Mark(int, int, int, int, std::vector<int>, std::vector<int>)':
Anthony.cpp:19:24: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   19 |       for (const auto& [u, i] : adj[v]) {
      |                        ^
Anthony.cpp:33:24: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   33 |       for (const auto& [u, i] : adj[v]) {
      |                        ^
Anthony.cpp:46:22: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   46 |     for (const auto& [u, i] : adj[v]) {
      |                      ^

Catherine.cpp: In function 'int Move(std::vector<int>)':
Catherine.cpp:34:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |       for (int i = 0; i < y.size(); ++i) {
      |                       ~~^~~~~~~~~~
Catherine.cpp:47:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |         if (sum == 0 || sum == y.size()) {
      |                         ~~~~^~~~~~~~~~~
Catherine.cpp:58:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |           for (int i = 0; i < y.size(); ++i) {
      |                           ~~^~~~~~~~~~
Catherine.cpp:69:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   69 |         for (int i = 0; i < y.size(); ++i) {
      |                         ~~^~~~~~~~~~
Catherine.cpp:103:46: warning: comparison of integer expressions of different signedness: 'const int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  103 |   if (max(count[0], max(count[1], count[2])) == y.size()) return 0;
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
Catherine.cpp:105:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  105 |   for (int i = 0; i < y.size(); ++i) if (y[i] == find) return i;
      |                   ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 3924 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 3924 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 9 ms 3880 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 9 ms 3880 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 592 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 2728 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 2696 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -