Submission #216043

# Submission time Handle Problem Language Result Execution time Memory
216043 2020-03-26T16:38:50 Z eriksuenderhauf Stray Cat (JOI20_stray) C++14
91 / 100
116 ms 16804 KB
#include "Anthony.h"
#include <bits/stdc++.h>
#define vi vector<int>
#define trav(x, a) for (const auto& x: a)
#define sz(x) (int)(x).size()
#define pb push_back
using namespace std;

namespace {
  const int N = 2e4 + 5;
  vi adj[N];
  int dp[N];
  string bl = "001011";
}

vi Mark(int N, int M, int A, int B, vi U, vi V) {
  for (int i = 0; i < M; i++)
    adj[U[i]].pb(i), adj[V[i]].pb(i);
  vi X(M);
  if (A > 2) {
    deque<int> pq;
    pq.pb(0);
    fill(dp, dp+N, N+1);
    dp[0] = 0;
    for (int i = 0; i < M; i++)
      X[i] = 2;
    while (!pq.empty()) {
      int u = pq.front(); pq.pop_front();
      trav(x, adj[u]) {
        int v = U[x]^V[x]^u;
        if (dp[v] > dp[u] + 1) {
          dp[v] = dp[u] + 1;
          pq.pb(v);
        }
        if (dp[v] == dp[u] + 1 || dp[v] == dp[u]) {
          X[x] = dp[u]%3;
        }
      }
    }
    return X;
  }
  function<void(int,int,int,int)> dfs = [&](int u, int p, int d, int l) {
    int f = (u != 0 && sz(adj[u]) > 2 ? 1 : 0);
    if (f) d = l ? 2 : 0;
    trav(x, adj[u]) {
      int v = U[x]^V[x]^u;
      if (v != p) {
        X[x] = bl[d%sz(bl)]-'0';
        dfs(v, u, d+1, X[x]^1);
      }
    }
  };
  dfs(0, -1, 0, 0);
  return X;
}
#include "Catherine.h"
#include <bits/stdc++.h>
#define vi vector<int>
#define sz(x) (int)(x).size()
#define pb push_back
using namespace std;
int A, B;

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

namespace {
  int lst = -1;
  bool fnd = 0;
  string bl = "001011001011";
  string rbl = "110100110100";
  string cur = "";
}

int Move(vi y) {
  if (A > 2) {
    if (~lst) y[lst]++;
    if (y[0] && y[1])
      return lst = 0;
    if (y[0] && y[2])
      return lst = 2;
    if (y[1] && y[2])
      return lst = 1;
    for (int i = 0; i < 3; i++)
      if (y[i])
        return lst = i;
  }
  if (fnd) {
    if (y[0]+y[1] > 1)
      y[lst]++;
    return lst = (y[0]==1 ? 0 : 1);
  }
  if (lst == -1) {
    if (y[0]+y[1] == 1) {
      fnd = 1;
      return lst = (y[0]==1 ? 0 : 1);
    }
    if (y[0]+y[1] > 2) {
      fnd = 1;
      return lst = (y[0]==1 ? 0 : 1);
    }
    lst = (y[0]>0 ? 0 : 1);
    y[lst]--;
    cur.pb((char)('0'+(y[0]>0 ? 0 : 1)));
    cur.pb((char)('0'+lst));
    return lst;
  }
  if (y[0]+y[1]==0) {
    fnd = 1;
    return -1;
  }
  if (y[0]+y[1]>1) {
    fnd = 1;
    y[lst]++;
    if (y[lst] == 1)
      return -1;
    return lst = lst^1;
  }
  vector<int> pos;
  for (int i = 0; i < 6; i++) {
    bool fl = 1;
    for (int j = 0; fl && j < sz(cur); j++)
      fl &= cur[j] == bl[i+j];
    if (fl)
      pos.pb(i);
    fl = 1;
    for (int j = 0; fl && j < sz(cur); j++)
      fl &= cur[j] == rbl[i+j];
    if (fl)
      pos.pb(~i);
  }
  if (sz(pos) == 1) {
    fnd = 1;
    return pos[0] >= 0 ? -1 : (lst = (y[0]==1 ? 0 : 1));
  }
  lst = (y[0]==1 ? 0 : 1);
  cur.pb((char)('0'+lst));
  return lst;
}
# Verdict Execution time Memory Grader output
1 Correct 66 ms 15472 KB Output is correct
2 Correct 10 ms 1536 KB Output is correct
3 Correct 53 ms 14840 KB Output is correct
4 Correct 116 ms 16784 KB Output is correct
5 Correct 82 ms 16804 KB Output is correct
6 Correct 75 ms 15332 KB Output is correct
7 Correct 71 ms 15452 KB Output is correct
8 Correct 87 ms 16204 KB Output is correct
9 Correct 87 ms 16188 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 66 ms 15472 KB Output is correct
2 Correct 10 ms 1536 KB Output is correct
3 Correct 53 ms 14840 KB Output is correct
4 Correct 116 ms 16784 KB Output is correct
5 Correct 82 ms 16804 KB Output is correct
6 Correct 75 ms 15332 KB Output is correct
7 Correct 71 ms 15452 KB Output is correct
8 Correct 87 ms 16204 KB Output is correct
9 Correct 87 ms 16188 KB Output is correct
10 Correct 59 ms 13392 KB Output is correct
11 Correct 54 ms 13432 KB Output is correct
12 Correct 55 ms 13484 KB Output is correct
13 Correct 71 ms 13436 KB Output is correct
14 Correct 59 ms 13480 KB Output is correct
15 Correct 73 ms 14024 KB Output is correct
16 Correct 80 ms 16116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 57 ms 13308 KB Output is correct
2 Correct 10 ms 1536 KB Output is correct
3 Correct 50 ms 12788 KB Output is correct
4 Correct 73 ms 14652 KB Output is correct
5 Correct 77 ms 14568 KB Output is correct
6 Correct 61 ms 13180 KB Output is correct
7 Correct 57 ms 13180 KB Output is correct
8 Correct 65 ms 13884 KB Output is correct
9 Correct 64 ms 13952 KB Output is correct
10 Correct 63 ms 13676 KB Output is correct
11 Correct 72 ms 13812 KB Output is correct
12 Correct 62 ms 13572 KB Output is correct
13 Correct 68 ms 13684 KB Output is correct
14 Correct 77 ms 13940 KB Output is correct
15 Correct 65 ms 13948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 57 ms 13308 KB Output is correct
2 Correct 10 ms 1536 KB Output is correct
3 Correct 50 ms 12788 KB Output is correct
4 Correct 73 ms 14652 KB Output is correct
5 Correct 77 ms 14568 KB Output is correct
6 Correct 61 ms 13180 KB Output is correct
7 Correct 57 ms 13180 KB Output is correct
8 Correct 65 ms 13884 KB Output is correct
9 Correct 64 ms 13952 KB Output is correct
10 Correct 63 ms 13676 KB Output is correct
11 Correct 72 ms 13812 KB Output is correct
12 Correct 62 ms 13572 KB Output is correct
13 Correct 68 ms 13684 KB Output is correct
14 Correct 77 ms 13940 KB Output is correct
15 Correct 65 ms 13948 KB Output is correct
16 Correct 55 ms 11624 KB Output is correct
17 Correct 50 ms 11632 KB Output is correct
18 Correct 59 ms 11504 KB Output is correct
19 Correct 65 ms 11644 KB Output is correct
20 Correct 73 ms 12076 KB Output is correct
21 Correct 57 ms 11888 KB Output is correct
22 Correct 82 ms 14060 KB Output is correct
23 Correct 71 ms 11604 KB Output is correct
24 Correct 55 ms 11564 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 1792 KB Output is correct
2 Correct 10 ms 1536 KB Output is correct
3 Correct 11 ms 1536 KB Output is correct
4 Correct 11 ms 1792 KB Output is correct
5 Correct 10 ms 1792 KB Output is correct
6 Correct 11 ms 1792 KB Output is correct
7 Correct 11 ms 1792 KB Output is correct
8 Correct 11 ms 1792 KB Output is correct
9 Correct 11 ms 1792 KB Output is correct
10 Correct 11 ms 1792 KB Output is correct
11 Correct 11 ms 1888 KB Output is correct
12 Correct 11 ms 1792 KB Output is correct
13 Correct 11 ms 1792 KB Output is correct
14 Correct 11 ms 1792 KB Output is correct
15 Correct 12 ms 1792 KB Output is correct
16 Correct 12 ms 1536 KB Output is correct
17 Correct 11 ms 1536 KB Output is correct
18 Correct 10 ms 1536 KB Output is correct
19 Correct 10 ms 1536 KB Output is correct
20 Correct 12 ms 1536 KB Output is correct
21 Correct 11 ms 1536 KB Output is correct
22 Correct 11 ms 1792 KB Output is correct
23 Correct 10 ms 1792 KB Output is correct
24 Correct 10 ms 1792 KB Output is correct
25 Correct 10 ms 1548 KB Output is correct
26 Correct 11 ms 1536 KB Output is correct
27 Correct 10 ms 1792 KB Output is correct
28 Correct 10 ms 1536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 60 ms 11196 KB Output is correct
2 Correct 65 ms 12620 KB Output is correct
3 Correct 10 ms 1536 KB Output is correct
4 Correct 53 ms 11076 KB Output is correct
5 Correct 66 ms 14452 KB Output is correct
6 Correct 74 ms 14404 KB Output is correct
7 Correct 57 ms 13564 KB Output is correct
8 Correct 54 ms 13516 KB Output is correct
9 Correct 74 ms 14264 KB Output is correct
10 Correct 71 ms 14440 KB Output is correct
11 Correct 76 ms 14260 KB Output is correct
12 Correct 78 ms 14444 KB Output is correct
13 Correct 91 ms 14416 KB Output is correct
14 Correct 84 ms 14420 KB Output is correct
15 Correct 87 ms 14408 KB Output is correct
16 Correct 75 ms 14416 KB Output is correct
17 Correct 69 ms 14068 KB Output is correct
18 Correct 71 ms 14068 KB Output is correct
19 Correct 68 ms 14076 KB Output is correct
20 Correct 77 ms 14068 KB Output is correct
21 Correct 92 ms 13976 KB Output is correct
22 Correct 71 ms 14076 KB Output is correct
23 Correct 51 ms 11124 KB Output is correct
24 Correct 53 ms 11364 KB Output is correct
25 Correct 67 ms 11748 KB Output is correct
26 Correct 52 ms 11764 KB Output is correct
27 Correct 57 ms 12672 KB Output is correct
28 Correct 56 ms 12532 KB Output is correct
29 Correct 64 ms 12660 KB Output is correct
30 Correct 71 ms 12796 KB Output is correct
31 Correct 54 ms 11628 KB Output is correct
32 Correct 57 ms 11220 KB Output is correct
33 Correct 60 ms 11668 KB Output is correct
34 Correct 60 ms 11724 KB Output is correct
35 Correct 65 ms 12660 KB Output is correct
36 Correct 61 ms 12664 KB Output is correct
37 Correct 68 ms 12592 KB Output is correct
38 Correct 76 ms 12660 KB Output is correct
39 Correct 71 ms 12620 KB Output is correct
40 Correct 68 ms 12552 KB Output is correct
41 Correct 79 ms 13300 KB Output is correct
42 Correct 71 ms 13300 KB Output is correct
43 Correct 78 ms 13256 KB Output is correct
44 Correct 64 ms 13460 KB Output is correct
45 Correct 73 ms 13324 KB Output is correct
46 Correct 62 ms 13368 KB Output is correct
47 Correct 62 ms 12412 KB Output is correct
48 Correct 86 ms 12356 KB Output is correct
49 Correct 61 ms 12300 KB Output is correct
50 Correct 64 ms 12404 KB Output is correct
51 Correct 55 ms 11536 KB Output is correct
52 Correct 57 ms 11556 KB Output is correct
53 Correct 53 ms 11516 KB Output is correct
54 Correct 57 ms 11436 KB Output is correct
55 Correct 52 ms 11508 KB Output is correct
56 Correct 56 ms 11508 KB Output is correct
57 Correct 60 ms 11568 KB Output is correct
58 Correct 61 ms 11372 KB Output is correct
59 Correct 54 ms 11524 KB Output is correct
60 Correct 56 ms 11508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 50 ms 11220 KB Output is correct
2 Correct 59 ms 12476 KB Output is correct
3 Correct 9 ms 1536 KB Output is correct
4 Correct 48 ms 11136 KB Output is correct
5 Correct 76 ms 14332 KB Output is correct
6 Correct 66 ms 14332 KB Output is correct
7 Correct 62 ms 13564 KB Output is correct
8 Correct 78 ms 13428 KB Output is correct
9 Correct 92 ms 14336 KB Output is correct
10 Correct 78 ms 14328 KB Output is correct
11 Correct 69 ms 14336 KB Output is correct
12 Correct 99 ms 14324 KB Output is correct
13 Correct 66 ms 14332 KB Output is correct
14 Correct 65 ms 14324 KB Output is correct
15 Correct 85 ms 14300 KB Output is correct
16 Correct 71 ms 14452 KB Output is correct
17 Correct 78 ms 13940 KB Output is correct
18 Correct 73 ms 14068 KB Output is correct
19 Correct 66 ms 14068 KB Output is correct
20 Correct 83 ms 14036 KB Output is correct
21 Correct 61 ms 13932 KB Output is correct
22 Incorrect 72 ms 14052 KB Wrong Answer [6]
23 Halted 0 ms 0 KB -