답안 #76579

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
76579 2018-09-15T00:48:01 Z Xylofo 자동 인형 (IOI18_doll) C++14
100 / 100
155 ms 11100 KB
#include <bits/stdc++.h>
#include "doll.h"
using namespace std;
#define rep(i,a,b) for(int i = a; i<b; ++i)
using vi = vector<int>;

void create_circuit(int m, vi a) {
  a.push_back(0);
  int n = a.size();
  int nn = (n+1)/2;
  vi x(nn),y(nn);
  auto add = [&](int e1, int e2) {
    y.push_back(-e1-1);
    x.push_back(-e2-1);
  };
  int l = 0, r = nn;
  while(r-l != 1) {
    for(; l+1 < r; l+=2) add(l, l+1);
    if(l < r) add(l++, -1);
    r = x.size();
  }
  rep(i,0,r) {
    if(x[i] == 0) x[i] = -r;
    if(y[i] == 0) y[i] = -r;
  }
  vi c(m+1, -r);
  int cnt = 0;
  int node = 0;
  vi state(x.size(), 0);
  int stCount = 0;
  while(cnt < n) {
    if(node < 0) {
      node = -node-1;
      state[node] = 1-state[node];
      stCount += 2*state[node]-1;
      int& nxt = state[node] ? x[node] : y[node];
      if(node < nn) {
        if(cnt < n-1 || stCount == 0)
          nxt = a[cnt++];
      }
      node = nxt;
    }
    else node = c[node];
  }
  // rep(i,0,m+1) cout << i << " " << c[i] << endl;
  // rep(i,0,r) cout << -(i+1) << " " << x[i] << " " << y[i] << endl;
  answer(c,x,y);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 50 ms 4264 KB Output is correct
3 Correct 61 ms 4376 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 12 ms 1356 KB Output is correct
6 Correct 73 ms 6568 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 50 ms 4264 KB Output is correct
3 Correct 61 ms 4376 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 12 ms 1356 KB Output is correct
6 Correct 73 ms 6568 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 98 ms 7324 KB Output is correct
9 Correct 95 ms 8024 KB Output is correct
10 Correct 155 ms 11100 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 50 ms 4264 KB Output is correct
3 Correct 61 ms 4376 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 12 ms 1356 KB Output is correct
6 Correct 73 ms 6568 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 98 ms 7324 KB Output is correct
9 Correct 95 ms 8024 KB Output is correct
10 Correct 155 ms 11100 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 140 ms 10488 KB Output is correct
15 Correct 98 ms 6708 KB Output is correct
16 Correct 153 ms 10180 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 141 ms 10768 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 2 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 98 ms 5532 KB Output is correct
3 Correct 83 ms 5536 KB Output is correct
4 Correct 128 ms 8440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 98 ms 5532 KB Output is correct
3 Correct 83 ms 5536 KB Output is correct
4 Correct 128 ms 8440 KB Output is correct
5 Correct 134 ms 9864 KB Output is correct
6 Correct 135 ms 9468 KB Output is correct
7 Correct 154 ms 9612 KB Output is correct
8 Correct 143 ms 9196 KB Output is correct
9 Correct 94 ms 5568 KB Output is correct
10 Correct 132 ms 9080 KB Output is correct
11 Correct 138 ms 8892 KB Output is correct
12 Correct 90 ms 5804 KB Output is correct
13 Correct 93 ms 6224 KB Output is correct
14 Correct 85 ms 6300 KB Output is correct
15 Correct 86 ms 6508 KB Output is correct
16 Correct 3 ms 460 KB Output is correct
17 Correct 80 ms 6316 KB Output is correct
18 Correct 85 ms 5760 KB Output is correct
19 Correct 79 ms 5828 KB Output is correct
20 Correct 142 ms 8932 KB Output is correct
21 Correct 144 ms 8708 KB Output is correct
22 Correct 125 ms 8864 KB Output is correct