Submission #216028

# Submission time Handle Problem Language Result Execution time Memory
216028 2020-03-26T16:06:41 Z eriksuenderhauf Stray Cat (JOI20_stray) C++14
91 / 100
91 ms 16756 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);
    trav(x, adj[u]) {
      int v = U[x]^V[x]^u;
      if (v != p) {
        X[x] = f ? l : bl[d%sz(bl)]-'0';
        dfs(v, u, d+(f?0: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);
    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 64 ms 15564 KB Output is correct
2 Correct 10 ms 1536 KB Output is correct
3 Correct 49 ms 14988 KB Output is correct
4 Correct 89 ms 16740 KB Output is correct
5 Correct 80 ms 16756 KB Output is correct
6 Correct 57 ms 15336 KB Output is correct
7 Correct 71 ms 15508 KB Output is correct
8 Correct 68 ms 16060 KB Output is correct
9 Correct 80 ms 16288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 64 ms 15564 KB Output is correct
2 Correct 10 ms 1536 KB Output is correct
3 Correct 49 ms 14988 KB Output is correct
4 Correct 89 ms 16740 KB Output is correct
5 Correct 80 ms 16756 KB Output is correct
6 Correct 57 ms 15336 KB Output is correct
7 Correct 71 ms 15508 KB Output is correct
8 Correct 68 ms 16060 KB Output is correct
9 Correct 80 ms 16288 KB Output is correct
10 Correct 65 ms 13428 KB Output is correct
11 Correct 55 ms 13444 KB Output is correct
12 Correct 62 ms 13412 KB Output is correct
13 Correct 60 ms 13420 KB Output is correct
14 Correct 78 ms 13680 KB Output is correct
15 Correct 86 ms 14160 KB Output is correct
16 Correct 69 ms 16244 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 55 ms 13196 KB Output is correct
2 Correct 10 ms 1536 KB Output is correct
3 Correct 52 ms 12864 KB Output is correct
4 Correct 66 ms 14504 KB Output is correct
5 Correct 70 ms 14580 KB Output is correct
6 Correct 58 ms 13180 KB Output is correct
7 Correct 61 ms 13188 KB Output is correct
8 Correct 59 ms 13940 KB Output is correct
9 Correct 65 ms 13880 KB Output is correct
10 Correct 61 ms 13644 KB Output is correct
11 Correct 68 ms 13552 KB Output is correct
12 Correct 63 ms 13732 KB Output is correct
13 Correct 69 ms 13704 KB Output is correct
14 Correct 64 ms 13932 KB Output is correct
15 Correct 69 ms 13796 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 55 ms 13196 KB Output is correct
2 Correct 10 ms 1536 KB Output is correct
3 Correct 52 ms 12864 KB Output is correct
4 Correct 66 ms 14504 KB Output is correct
5 Correct 70 ms 14580 KB Output is correct
6 Correct 58 ms 13180 KB Output is correct
7 Correct 61 ms 13188 KB Output is correct
8 Correct 59 ms 13940 KB Output is correct
9 Correct 65 ms 13880 KB Output is correct
10 Correct 61 ms 13644 KB Output is correct
11 Correct 68 ms 13552 KB Output is correct
12 Correct 63 ms 13732 KB Output is correct
13 Correct 69 ms 13704 KB Output is correct
14 Correct 64 ms 13932 KB Output is correct
15 Correct 69 ms 13796 KB Output is correct
16 Correct 52 ms 11640 KB Output is correct
17 Correct 54 ms 11568 KB Output is correct
18 Correct 50 ms 11512 KB Output is correct
19 Correct 65 ms 11524 KB Output is correct
20 Correct 72 ms 12176 KB Output is correct
21 Correct 69 ms 11892 KB Output is correct
22 Correct 67 ms 14068 KB Output is correct
23 Correct 57 ms 11640 KB Output is correct
24 Correct 59 ms 11524 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 1536 KB Output is correct
2 Correct 10 ms 1536 KB Output is correct
3 Correct 10 ms 1792 KB Output is correct
4 Correct 10 ms 1792 KB Output is correct
5 Correct 11 ms 1792 KB Output is correct
6 Correct 11 ms 1792 KB Output is correct
7 Correct 10 ms 1792 KB Output is correct
8 Correct 11 ms 1792 KB Output is correct
9 Correct 10 ms 1792 KB Output is correct
10 Correct 10 ms 1792 KB Output is correct
11 Correct 11 ms 1856 KB Output is correct
12 Correct 10 ms 1888 KB Output is correct
13 Correct 10 ms 1792 KB Output is correct
14 Correct 10 ms 1792 KB Output is correct
15 Correct 11 ms 1792 KB Output is correct
16 Correct 11 ms 1536 KB Output is correct
17 Correct 11 ms 1556 KB Output is correct
18 Correct 10 ms 1792 KB Output is correct
19 Correct 10 ms 1792 KB Output is correct
20 Correct 11 ms 1792 KB Output is correct
21 Correct 11 ms 1792 KB Output is correct
22 Correct 13 ms 1792 KB Output is correct
23 Correct 11 ms 1536 KB Output is correct
24 Correct 11 ms 1536 KB Output is correct
25 Correct 11 ms 1792 KB Output is correct
26 Correct 10 ms 1756 KB Output is correct
27 Correct 13 ms 1792 KB Output is correct
28 Correct 13 ms 1792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 74 ms 11164 KB Output is correct
2 Correct 81 ms 12832 KB Output is correct
3 Correct 10 ms 1536 KB Output is correct
4 Correct 48 ms 11120 KB Output is correct
5 Correct 74 ms 14708 KB Output is correct
6 Correct 89 ms 14708 KB Output is correct
7 Correct 53 ms 13744 KB Output is correct
8 Correct 61 ms 13752 KB Output is correct
9 Correct 74 ms 14764 KB Output is correct
10 Correct 65 ms 14580 KB Output is correct
11 Correct 91 ms 14616 KB Output is correct
12 Correct 86 ms 14628 KB Output is correct
13 Correct 70 ms 14580 KB Output is correct
14 Correct 69 ms 14616 KB Output is correct
15 Correct 77 ms 14768 KB Output is correct
16 Correct 80 ms 14764 KB Output is correct
17 Correct 68 ms 14372 KB Output is correct
18 Correct 73 ms 14340 KB Output is correct
19 Correct 71 ms 14196 KB Output is correct
20 Correct 65 ms 14352 KB Output is correct
21 Correct 61 ms 14324 KB Output is correct
22 Correct 67 ms 14376 KB Output is correct
23 Correct 59 ms 11048 KB Output is correct
24 Correct 65 ms 11228 KB Output is correct
25 Correct 73 ms 11784 KB Output is correct
26 Correct 57 ms 11712 KB Output is correct
27 Correct 69 ms 12924 KB Output is correct
28 Correct 75 ms 12876 KB Output is correct
29 Correct 81 ms 12840 KB Output is correct
30 Correct 70 ms 12928 KB Output is correct
31 Correct 56 ms 11124 KB Output is correct
32 Correct 59 ms 11348 KB Output is correct
33 Correct 58 ms 11768 KB Output is correct
34 Correct 53 ms 11900 KB Output is correct
35 Correct 64 ms 12660 KB Output is correct
36 Correct 74 ms 12652 KB Output is correct
37 Correct 71 ms 12644 KB Output is correct
38 Correct 61 ms 12788 KB Output is correct
39 Correct 67 ms 12784 KB Output is correct
40 Correct 71 ms 12624 KB Output is correct
41 Correct 65 ms 13564 KB Output is correct
42 Correct 68 ms 13440 KB Output is correct
43 Correct 64 ms 13556 KB Output is correct
44 Correct 63 ms 13420 KB Output is correct
45 Correct 63 ms 13556 KB Output is correct
46 Correct 64 ms 13488 KB Output is correct
47 Correct 61 ms 12404 KB Output is correct
48 Correct 65 ms 12500 KB Output is correct
49 Correct 69 ms 12404 KB Output is correct
50 Correct 77 ms 12536 KB Output is correct
51 Correct 57 ms 11236 KB Output is correct
52 Correct 55 ms 11324 KB Output is correct
53 Correct 57 ms 11252 KB Output is correct
54 Correct 75 ms 11244 KB Output is correct
55 Correct 54 ms 11260 KB Output is correct
56 Correct 67 ms 11252 KB Output is correct
57 Correct 71 ms 11636 KB Output is correct
58 Correct 65 ms 11520 KB Output is correct
59 Correct 75 ms 11508 KB Output is correct
60 Correct 78 ms 11576 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 54 ms 11128 KB Output is correct
2 Correct 58 ms 12532 KB Output is correct
3 Correct 10 ms 1536 KB Output is correct
4 Correct 48 ms 11112 KB Output is correct
5 Correct 67 ms 14580 KB Output is correct
6 Correct 67 ms 14588 KB Output is correct
7 Incorrect 73 ms 13676 KB Wrong Answer [6]
8 Halted 0 ms 0 KB -