답안 #713815

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
713815 2023-03-23T05:30:29 Z LittleOrange 자동 인형 (IOI18_doll) C++17
100 / 100
98 ms 11056 KB
#include "doll.h"
#include <bits/stdc++.h>
using namespace std;
using ll = int;
const ll inf = 1e8;
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;
    }
    for (int i = 1; i <= M; ++i){
        C[i] = -1;
    }
    ll GN = 1 << (__lg(N - 1) + 1);
    A.push_back(0);
    vector<int> X,Y;
    ll it = 0;
    function<ll(ll, ll,ll,ll)> dfs;
    dfs = [&](ll cnt, ll width, ll st, ll lv){
        //cerr << "dfs " << cnt << " " << width << " " << st << " " << lv << "\n";
        if (width == 1){
            return inf+st;
        }
        ll i = it++;
        X.emplace_back();
        Y.emplace_back();
        if (width>=cnt*2){
            X[i] = -1;
            Y[i] = dfs(cnt,width/2,st+(1<<lv),lv+1);
        }else{
            ll leftsize = 1<<__lg(cnt-1);
            X[i] = dfs(cnt-leftsize,leftsize,st,lv+1);
            Y[i] = dfs(leftsize,leftsize,st+(1<<lv),lv+1);
        }
        return -1 - i;
    };
    dfs(N, GN,0,0);
    //cerr << "S=" << X.size() << endl;
    //for(ll i = 0;i<X.size();i++) cerr << X[i] << " \n"[i+1==X.size()];
    //for(ll i = 0;i<Y.size();i++) cerr << Y[i] << " \n"[i+1==Y.size()];
    vector<pair<ll,ll*>> v;
    for(ll i = 0;i<X.size();i++) if (X[i]>=inf) v.push_back({X[i],&X[i]});
    for(ll i = 0;i<Y.size();i++) if (Y[i]>=inf) v.push_back({Y[i],&Y[i]});
    sort(v.begin(),v.end());
    for(ll i = 0;i<N;i++){
        *v[i].second = A[i+1];
    }
    answer(C, X, Y);
}

Compilation message

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:48:19: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |     for(ll i = 0;i<X.size();i++) if (X[i]>=inf) v.push_back({X[i],&X[i]});
      |                  ~^~~~~~~~~
doll.cpp:49:19: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |     for(ll i = 0;i<Y.size();i++) if (Y[i]>=inf) v.push_back({Y[i],&Y[i]});
      |                  ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 34 ms 4812 KB Output is correct
3 Correct 29 ms 4620 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 10 ms 1364 KB Output is correct
6 Correct 48 ms 6516 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 34 ms 4812 KB Output is correct
3 Correct 29 ms 4620 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 10 ms 1364 KB Output is correct
6 Correct 48 ms 6516 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 53 ms 7564 KB Output is correct
9 Correct 74 ms 7932 KB Output is correct
10 Correct 85 ms 11056 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 228 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 34 ms 4812 KB Output is correct
3 Correct 29 ms 4620 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 10 ms 1364 KB Output is correct
6 Correct 48 ms 6516 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 53 ms 7564 KB Output is correct
9 Correct 74 ms 7932 KB Output is correct
10 Correct 85 ms 11056 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 228 KB Output is correct
14 Correct 87 ms 10712 KB Output is correct
15 Correct 53 ms 7020 KB Output is correct
16 Correct 83 ms 10516 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 296 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 83 ms 10784 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 48 ms 6980 KB Output is correct
3 Correct 50 ms 6768 KB Output is correct
4 Correct 98 ms 9864 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 48 ms 6980 KB Output is correct
3 Correct 50 ms 6768 KB Output is correct
4 Correct 98 ms 9864 KB Output is correct
5 Correct 80 ms 10356 KB Output is correct
6 Correct 77 ms 10152 KB Output is correct
7 Correct 78 ms 10176 KB Output is correct
8 Correct 74 ms 9932 KB Output is correct
9 Correct 46 ms 6768 KB Output is correct
10 Correct 76 ms 9984 KB Output is correct
11 Correct 73 ms 9904 KB Output is correct
12 Correct 48 ms 6716 KB Output is correct
13 Correct 50 ms 6980 KB Output is correct
14 Correct 49 ms 6772 KB Output is correct
15 Correct 57 ms 6900 KB Output is correct
16 Correct 3 ms 596 KB Output is correct
17 Correct 46 ms 6980 KB Output is correct
18 Correct 58 ms 6908 KB Output is correct
19 Correct 48 ms 6788 KB Output is correct
20 Correct 79 ms 9940 KB Output is correct
21 Correct 77 ms 9812 KB Output is correct
22 Correct 76 ms 9916 KB Output is correct