답안 #421650

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
421650 2021-06-09T10:31:31 Z marcipan5000 자동 인형 (IOI18_doll) C++14
53 / 100
151 ms 16784 KB
#include "doll.h"
#include <bits/stdc++.h>

using namespace std;

vector<int> t[100001];
vector<int> c,x,y;
int p=-1;
int g;
int s;

int rev(int q,int w) {
  int ans=0;
  for (int i=0;i<q;i++) {
    if ((w>>i)%2==1) {
      ans=(ans^(1<<(q-i-1)));
    }
  }
  return(ans);
}

int build(int a,int b,int r,int z) {
  if (a==b) {
    return(t[z][rev(r,a)]);
  }
  int x1,y1;
  x1=build(a,(a+b)/2,r,z);
  y1=build((a+b)/2+1,b,r,z);
  /* cout << a << " " << b << " " << r << " " << z << " " << x1 << " " << y1 << endl; */
  if (x1!=y1) {
    int p2=p; p--;
    x[-1*p2-1]=x1;
    y[-1*p2-1]=y1;
    return(p2);
  }
  return(x1);
}

void create_circuit (int M, std::vector<int> A) {
    int n=A.size();

    for (int i=0;i<n-1;i++) {
        t[A[i]].push_back(A[i+1]);
    }

    t[A[n-1]].push_back(0);
    t[0].push_back(A[0]);
    
    x.resize(400000);
    y.resize(400000);

    int p0,p1;

    for (int i=0;i<=M;i++) {
        if (t[i].size()==0) {
          c.push_back(0);
        }
        if (t[i].size()==1) {
          c.push_back(t[i][0]);
        }
        if (t[i].size()>1) {
          g=pow(2,int(log2(int(t[i].size())-1))+1);
          s=t[i].size()-1;
          t[i].resize(g);
          t[i][g-1]=t[i][s];
          for (int j=s;j<g-1;j++) {
            t[i][j]=1e9;
          }
          p0=-1*p-1;
          c.push_back(build(0,g-1,int(log2(g)),i));
          p1=-1*p-1;
          for (int j=p0;j<p1;j++) {
            if (x[j]==1e9) {
              x[j]=c[i];
            }
            if (y[j]==1e9) {
              y[j]=c[i];
            }
          }
        }
    }
    
    x.resize(-1*p-1);
    y.resize(-1*p-1);

    answer(c,x,y);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 5708 KB Output is correct
2 Correct 30 ms 9548 KB Output is correct
3 Correct 25 ms 9232 KB Output is correct
4 Correct 3 ms 5708 KB Output is correct
5 Correct 13 ms 6980 KB Output is correct
6 Correct 38 ms 10984 KB Output is correct
7 Correct 3 ms 5708 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 5708 KB Output is correct
2 Correct 30 ms 9548 KB Output is correct
3 Correct 25 ms 9232 KB Output is correct
4 Correct 3 ms 5708 KB Output is correct
5 Correct 13 ms 6980 KB Output is correct
6 Correct 38 ms 10984 KB Output is correct
7 Correct 3 ms 5708 KB Output is correct
8 Correct 63 ms 11228 KB Output is correct
9 Correct 62 ms 11676 KB Output is correct
10 Correct 97 ms 13288 KB Output is correct
11 Correct 3 ms 5708 KB Output is correct
12 Correct 3 ms 5708 KB Output is correct
13 Correct 3 ms 5708 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 5708 KB Output is correct
2 Correct 30 ms 9548 KB Output is correct
3 Correct 25 ms 9232 KB Output is correct
4 Correct 3 ms 5708 KB Output is correct
5 Correct 13 ms 6980 KB Output is correct
6 Correct 38 ms 10984 KB Output is correct
7 Correct 3 ms 5708 KB Output is correct
8 Correct 63 ms 11228 KB Output is correct
9 Correct 62 ms 11676 KB Output is correct
10 Correct 97 ms 13288 KB Output is correct
11 Correct 3 ms 5708 KB Output is correct
12 Correct 3 ms 5708 KB Output is correct
13 Correct 3 ms 5708 KB Output is correct
14 Correct 103 ms 14020 KB Output is correct
15 Correct 57 ms 9836 KB Output is correct
16 Correct 83 ms 11992 KB Output is correct
17 Correct 4 ms 5708 KB Output is correct
18 Correct 3 ms 5708 KB Output is correct
19 Correct 3 ms 5708 KB Output is correct
20 Correct 95 ms 13384 KB Output is correct
21 Correct 4 ms 5708 KB Output is correct
22 Correct 3 ms 5708 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 5708 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 4 ms 5708 KB Output is partially correct
2 Correct 31 ms 7388 KB Output is correct
3 Partially correct 98 ms 12740 KB Output is partially correct
4 Correct 92 ms 11444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 4 ms 5708 KB Output is partially correct
2 Correct 31 ms 7388 KB Output is correct
3 Partially correct 98 ms 12740 KB Output is partially correct
4 Correct 92 ms 11444 KB Output is correct
5 Partially correct 114 ms 15524 KB Output is partially correct
6 Partially correct 122 ms 16260 KB Output is partially correct
7 Partially correct 118 ms 16044 KB Output is partially correct
8 Partially correct 133 ms 16648 KB Output is partially correct
9 Partially correct 91 ms 12764 KB Output is partially correct
10 Partially correct 151 ms 16600 KB Output is partially correct
11 Partially correct 126 ms 16784 KB Output is partially correct
12 Partially correct 87 ms 13124 KB Output is partially correct
13 Partially correct 83 ms 12644 KB Output is partially correct
14 Partially correct 80 ms 12428 KB Output is partially correct
15 Partially correct 78 ms 12192 KB Output is partially correct
16 Partially correct 5 ms 5964 KB Output is partially correct
17 Partially correct 68 ms 11312 KB Output is partially correct
18 Partially correct 71 ms 11288 KB Output is partially correct
19 Partially correct 78 ms 11680 KB Output is partially correct
20 Partially correct 106 ms 13592 KB Output is partially correct
21 Partially correct 119 ms 15176 KB Output is partially correct
22 Partially correct 89 ms 12908 KB Output is partially correct