답안 #713763

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
713763 2023-03-23T02:41:17 Z LittleOrange 자동 인형 (IOI18_doll) C++17
63 / 100
107 ms 14424 KB
#include "doll.h"
#include<bits/stdc++.h>
using namespace std;
using ll = int;
 
void create_circuit(int M, std::vector<int> A) {
  int N = A.size();
  std::vector<int> C(M + 1,0);
  C[0] = A[0];
  if (N == 1){
    for (int i = 1; i <= M; ++i) C[i] = 0;
    vector<int> X,Y; 
    answer(C, X, Y);
    return;
  }else if (N==16){
    
  for (int i = 1; i <= M; ++i) {
    C[i] = -1;
  }
  ll GN = 1<<(__lg(N-1)+1);
  while (A.size()<GN) A.push_back(-1);
  A.push_back(0);
  vector<int> X(GN-1),Y(GN-1);
  ll it = 0;
  function<ll(ll,ll,ll)> dfs;
  dfs = [&](ll cnt, ll st, ll lv){
    if (cnt==1){
        return A[st+1];
    }
    ll i = it++;
    X[i] = dfs(cnt-cnt/2,st,lv+1);
    Y[i] = dfs(cnt/2,st+(1<<lv),lv+1);
    return -1-i;
  };
  dfs(GN,0,0);
  answer(C, X, Y);
  return;
  }
  A.push_back(0);
  vector<vector<ll>> nxt(M);
  for(ll i = 0;i<N;i++){
    nxt[A[i]-1].push_back(A[i+1]);
  }
  for(auto &o : nxt){
    if (o.size()>2) {
        ll old = o.back();
        o.pop_back();
        o.resize(1<<(__lg(o.size())+1),-1);
        o.back() = old;
    }
  }
  vector<int> X,Y;
  ll it = 0;
  vector<ll> CUR;
  ll root;
  function<ll(ll,ll,ll)> dfs;
  dfs = [&](ll cnt, ll st, ll lv){
    //cerr << "dfs " << cnt << " " << st << " " << lv << " " << CUR[st] << "\n";
    if (cnt==1){
        return CUR[st]==-1?root:CUR[st];
    }
    ll i = it++;
    X.emplace_back();
    Y.emplace_back();
    X[i] = dfs(cnt-cnt/2,st,lv+1);
    Y[i] = dfs(cnt/2,st+(1<<lv),lv+1);
    return -1-i;
  };
  for(ll i = 0;i<M;i++){
    CUR = nxt[i];
    if (CUR.size()>1){
        C[i+1] = root = -1-it;
        dfs(CUR.size(),0,0);
    }else if(CUR.size()==1){
        C[i+1] = CUR[0];
    }
  }
  for(ll i = 0;i<N;i++) {
    //cerr << "nxt " << i << ":";
    //for(ll j : nxt[i]) cerr << " " << j;
    //cerr << "\n";
  }
  answer(C, X, Y);
}

Compilation message

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:21:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'int'} [-Wsign-compare]
   21 |   while (A.size()<GN) A.push_back(-1);
      |          ~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 30 ms 6352 KB Output is correct
3 Correct 23 ms 5072 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 9 ms 1364 KB Output is correct
6 Correct 30 ms 7628 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 30 ms 6352 KB Output is correct
3 Correct 23 ms 5072 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 9 ms 1364 KB Output is correct
6 Correct 30 ms 7628 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 50 ms 7232 KB Output is correct
9 Correct 63 ms 8528 KB Output is correct
10 Correct 64 ms 11324 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 30 ms 6352 KB Output is correct
3 Correct 23 ms 5072 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 9 ms 1364 KB Output is correct
6 Correct 30 ms 7628 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 50 ms 7232 KB Output is correct
9 Correct 63 ms 8528 KB Output is correct
10 Correct 64 ms 11324 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 92 ms 10928 KB Output is correct
15 Correct 43 ms 6000 KB Output is correct
16 Correct 64 ms 8620 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 73 ms 10604 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 296 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 1 ms 216 KB Output is partially correct
2 Correct 37 ms 6828 KB Output is correct
3 Partially correct 62 ms 9688 KB Output is partially correct
4 Partially correct 72 ms 10408 KB Output is partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 1 ms 216 KB Output is partially correct
2 Correct 37 ms 6828 KB Output is correct
3 Partially correct 62 ms 9688 KB Output is partially correct
4 Partially correct 72 ms 10408 KB Output is partially correct
5 Partially correct 105 ms 12080 KB Output is partially correct
6 Partially correct 96 ms 12684 KB Output is partially correct
7 Partially correct 107 ms 12484 KB Output is partially correct
8 Partially correct 105 ms 12876 KB Output is partially correct
9 Partially correct 66 ms 9928 KB Output is partially correct
10 Partially correct 100 ms 14424 KB Output is partially correct
11 Partially correct 100 ms 14296 KB Output is partially correct
12 Partially correct 63 ms 9264 KB Output is partially correct
13 Partially correct 67 ms 8316 KB Output is partially correct
14 Partially correct 69 ms 8180 KB Output is partially correct
15 Partially correct 61 ms 7976 KB Output is partially correct
16 Partially correct 2 ms 468 KB Output is partially correct
17 Partially correct 53 ms 7136 KB Output is partially correct
18 Partially correct 56 ms 7220 KB Output is partially correct
19 Partially correct 56 ms 7508 KB Output is partially correct
20 Partially correct 75 ms 9816 KB Output is partially correct
21 Partially correct 90 ms 11692 KB Output is partially correct
22 Partially correct 69 ms 9268 KB Output is partially correct