답안 #216039

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
216039 2020-03-26T16:36:08 Z eriksuenderhauf 길고양이 (JOI20_stray) C++14
91 / 100
93 ms 16764 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);
    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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 72 ms 15636 KB Output is correct
2 Correct 10 ms 1536 KB Output is correct
3 Correct 53 ms 14968 KB Output is correct
4 Correct 79 ms 16764 KB Output is correct
5 Correct 74 ms 16756 KB Output is correct
6 Correct 60 ms 15352 KB Output is correct
7 Correct 63 ms 15448 KB Output is correct
8 Correct 73 ms 16116 KB Output is correct
9 Correct 83 ms 16112 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 72 ms 15636 KB Output is correct
2 Correct 10 ms 1536 KB Output is correct
3 Correct 53 ms 14968 KB Output is correct
4 Correct 79 ms 16764 KB Output is correct
5 Correct 74 ms 16756 KB Output is correct
6 Correct 60 ms 15352 KB Output is correct
7 Correct 63 ms 15448 KB Output is correct
8 Correct 73 ms 16116 KB Output is correct
9 Correct 83 ms 16112 KB Output is correct
10 Correct 51 ms 13440 KB Output is correct
11 Correct 63 ms 13552 KB Output is correct
12 Correct 68 ms 13388 KB Output is correct
13 Correct 61 ms 13432 KB Output is correct
14 Correct 59 ms 13692 KB Output is correct
15 Correct 81 ms 14064 KB Output is correct
16 Correct 71 ms 16316 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 56 ms 13172 KB Output is correct
2 Correct 10 ms 1536 KB Output is correct
3 Correct 48 ms 12796 KB Output is correct
4 Correct 81 ms 14528 KB Output is correct
5 Correct 81 ms 14436 KB Output is correct
6 Correct 56 ms 13164 KB Output is correct
7 Correct 63 ms 13180 KB Output is correct
8 Correct 66 ms 13948 KB Output is correct
9 Correct 68 ms 13940 KB Output is correct
10 Correct 66 ms 13556 KB Output is correct
11 Correct 60 ms 13676 KB Output is correct
12 Correct 60 ms 13692 KB Output is correct
13 Correct 74 ms 13548 KB Output is correct
14 Correct 77 ms 13936 KB Output is correct
15 Correct 71 ms 13932 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 56 ms 13172 KB Output is correct
2 Correct 10 ms 1536 KB Output is correct
3 Correct 48 ms 12796 KB Output is correct
4 Correct 81 ms 14528 KB Output is correct
5 Correct 81 ms 14436 KB Output is correct
6 Correct 56 ms 13164 KB Output is correct
7 Correct 63 ms 13180 KB Output is correct
8 Correct 66 ms 13948 KB Output is correct
9 Correct 68 ms 13940 KB Output is correct
10 Correct 66 ms 13556 KB Output is correct
11 Correct 60 ms 13676 KB Output is correct
12 Correct 60 ms 13692 KB Output is correct
13 Correct 74 ms 13548 KB Output is correct
14 Correct 77 ms 13936 KB Output is correct
15 Correct 71 ms 13932 KB Output is correct
16 Correct 50 ms 11640 KB Output is correct
17 Correct 57 ms 11580 KB Output is correct
18 Correct 51 ms 11592 KB Output is correct
19 Correct 69 ms 11504 KB Output is correct
20 Correct 59 ms 12144 KB Output is correct
21 Correct 78 ms 11972 KB Output is correct
22 Correct 69 ms 14204 KB Output is correct
23 Correct 61 ms 11688 KB Output is correct
24 Correct 56 ms 11592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 1792 KB Output is correct
2 Correct 11 ms 1536 KB Output is correct
3 Correct 10 ms 1744 KB Output is correct
4 Correct 10 ms 1792 KB Output is correct
5 Correct 10 ms 1832 KB Output is correct
6 Correct 10 ms 1792 KB Output is correct
7 Correct 10 ms 1792 KB Output is correct
8 Correct 10 ms 1792 KB Output is correct
9 Correct 10 ms 1792 KB Output is correct
10 Correct 13 ms 1792 KB Output is correct
11 Correct 11 ms 1792 KB Output is correct
12 Correct 11 ms 1888 KB Output is correct
13 Correct 10 ms 1536 KB Output is correct
14 Correct 11 ms 1792 KB Output is correct
15 Correct 13 ms 1792 KB Output is correct
16 Correct 11 ms 1536 KB Output is correct
17 Correct 10 ms 1536 KB Output is correct
18 Correct 14 ms 1536 KB Output is correct
19 Correct 11 ms 1536 KB Output is correct
20 Correct 10 ms 1536 KB Output is correct
21 Correct 10 ms 1536 KB Output is correct
22 Correct 11 ms 1536 KB Output is correct
23 Correct 10 ms 1552 KB Output is correct
24 Correct 12 ms 1744 KB Output is correct
25 Correct 11 ms 1536 KB Output is correct
26 Correct 10 ms 1536 KB Output is correct
27 Correct 10 ms 1536 KB Output is correct
28 Correct 10 ms 1536 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 50 ms 11116 KB Output is correct
2 Correct 57 ms 12532 KB Output is correct
3 Correct 10 ms 1536 KB Output is correct
4 Correct 47 ms 11136 KB Output is correct
5 Correct 74 ms 14492 KB Output is correct
6 Correct 78 ms 14336 KB Output is correct
7 Correct 54 ms 13520 KB Output is correct
8 Correct 55 ms 13436 KB Output is correct
9 Correct 71 ms 14344 KB Output is correct
10 Correct 79 ms 14444 KB Output is correct
11 Correct 76 ms 14428 KB Output is correct
12 Correct 71 ms 14344 KB Output is correct
13 Correct 73 ms 14376 KB Output is correct
14 Correct 73 ms 14352 KB Output is correct
15 Correct 93 ms 14428 KB Output is correct
16 Correct 73 ms 14452 KB Output is correct
17 Correct 69 ms 14068 KB Output is correct
18 Correct 71 ms 14048 KB Output is correct
19 Correct 70 ms 13932 KB Output is correct
20 Correct 72 ms 14096 KB Output is correct
21 Correct 81 ms 13940 KB Output is correct
22 Correct 73 ms 14068 KB Output is correct
23 Correct 57 ms 11132 KB Output is correct
24 Correct 64 ms 11336 KB Output is correct
25 Correct 62 ms 11732 KB Output is correct
26 Correct 53 ms 11644 KB Output is correct
27 Correct 76 ms 12660 KB Output is correct
28 Correct 80 ms 12780 KB Output is correct
29 Correct 61 ms 12788 KB Output is correct
30 Correct 59 ms 12916 KB Output is correct
31 Correct 56 ms 11220 KB Output is correct
32 Correct 56 ms 11352 KB Output is correct
33 Correct 51 ms 11720 KB Output is correct
34 Correct 64 ms 11752 KB Output is correct
35 Correct 71 ms 12668 KB Output is correct
36 Correct 69 ms 12660 KB Output is correct
37 Correct 59 ms 12696 KB Output is correct
38 Correct 71 ms 12620 KB Output is correct
39 Correct 63 ms 12652 KB Output is correct
40 Correct 78 ms 12596 KB Output is correct
41 Correct 70 ms 13260 KB Output is correct
42 Correct 67 ms 13296 KB Output is correct
43 Correct 75 ms 13292 KB Output is correct
44 Correct 71 ms 13344 KB Output is correct
45 Correct 79 ms 13308 KB Output is correct
46 Correct 62 ms 13380 KB Output is correct
47 Correct 63 ms 12416 KB Output is correct
48 Correct 61 ms 12392 KB Output is correct
49 Correct 60 ms 12344 KB Output is correct
50 Correct 87 ms 12396 KB Output is correct
51 Correct 62 ms 11540 KB Output is correct
52 Correct 56 ms 11516 KB Output is correct
53 Correct 55 ms 11528 KB Output is correct
54 Correct 56 ms 11524 KB Output is correct
55 Correct 51 ms 11388 KB Output is correct
56 Correct 53 ms 11516 KB Output is correct
57 Correct 58 ms 11572 KB Output is correct
58 Correct 52 ms 11408 KB Output is correct
59 Correct 59 ms 11548 KB Output is correct
60 Correct 57 ms 11604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 54 ms 11124 KB Output is correct
2 Correct 56 ms 12276 KB Output is correct
3 Correct 10 ms 1536 KB Output is correct
4 Correct 48 ms 11112 KB Output is correct
5 Correct 64 ms 14344 KB Output is correct
6 Correct 71 ms 14404 KB Output is correct
7 Incorrect 53 ms 13476 KB Wrong Answer [6]
8 Halted 0 ms 0 KB -