답안 #83467

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
83467 2018-11-08T07:26:33 Z aquablitz11 자동 인형 (IOI18_doll) C++14
100 / 100
143 ms 10460 KB
#include <bits/stdc++.h>
#include "doll.h"
using namespace std;

vector<int> X, Y;
int get(int l, int r) {
    X.push_back(l);
    Y.push_back(r);
    return -X.size();
}
int solve(vector<int> &A) {
    vector<int> L, R;
    bool diff = false;
    for (int i = 0; i < A.size(); ++i) {
        if (A[i] != A[0]) diff = true;
        if (i%2==0) L.push_back(A[i]);
        else R.push_back(A[i]);
    }
    if (!diff)
        return A[0];
    A.clear();
    int l = solve(L);
    int r = solve(R);
    return get(l, r);
}
int rev(int n, int i) {
    int val = 0;
    while (n--) {
        val <<= 1;
        val |= i&1;
        i >>= 1;
    }
    return val;
}

void create_circuit(int m, vector<int> A) {
    A.push_back(0);
    int n = A.size();
    int k = 0;
    while ((1<<k) < n) ++k;
    vector<int> B(1<<k, 0);
    for (int i = 0; i < n; ++i) {
        int r = rev(k, (1<<k)-i-1);
        B[r] = 1;
    }
    int c = 0;
    for (int i = 0; i < (1<<k); ++i) {
        if (B[i]) B[i] = A[c++];
        else B[i] = m+1;
    }
    int u = solve(B);
    for (int i = 0; i < X.size(); ++i) {
        if (X[i] == m+1) X[i] = u;
        if (Y[i] == m+1) Y[i] = u;
    }
    vector<int> C(m+1, u);
    answer(C, X, Y);
}

Compilation message

doll.cpp: In function 'int solve(std::vector<int>&)':
doll.cpp:14:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     for (int i = 0; i < A.size(); ++i) {
      |                     ~~^~~~~~~~~~
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:52:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |     for (int i = 0; i < X.size(); ++i) {
      |                     ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 57 ms 4700 KB Output is correct
3 Correct 55 ms 4320 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 12 ms 1356 KB Output is correct
6 Correct 78 ms 6524 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 57 ms 4700 KB Output is correct
3 Correct 55 ms 4320 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 12 ms 1356 KB Output is correct
6 Correct 78 ms 6524 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 89 ms 7364 KB Output is correct
9 Correct 103 ms 8168 KB Output is correct
10 Correct 137 ms 10460 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 57 ms 4700 KB Output is correct
3 Correct 55 ms 4320 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 12 ms 1356 KB Output is correct
6 Correct 78 ms 6524 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 89 ms 7364 KB Output is correct
9 Correct 103 ms 8168 KB Output is correct
10 Correct 137 ms 10460 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 143 ms 9900 KB Output is correct
15 Correct 95 ms 6848 KB Output is correct
16 Correct 129 ms 9416 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 143 ms 10132 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 328 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 2 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 204 KB Output is correct
2 Correct 24 ms 4388 KB Output is correct
3 Correct 31 ms 4392 KB Output is correct
4 Correct 34 ms 4888 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 204 KB Output is correct
2 Correct 24 ms 4388 KB Output is correct
3 Correct 31 ms 4392 KB Output is correct
4 Correct 34 ms 4888 KB Output is correct
5 Correct 138 ms 9364 KB Output is correct
6 Correct 127 ms 9100 KB Output is correct
7 Correct 126 ms 9032 KB Output is correct
8 Correct 125 ms 8816 KB Output is correct
9 Correct 70 ms 5744 KB Output is correct
10 Correct 117 ms 8732 KB Output is correct
11 Correct 122 ms 8420 KB Output is correct
12 Correct 86 ms 6164 KB Output is correct
13 Correct 97 ms 6768 KB Output is correct
14 Correct 88 ms 6696 KB Output is correct
15 Correct 90 ms 6724 KB Output is correct
16 Correct 4 ms 460 KB Output is correct
17 Correct 81 ms 6500 KB Output is correct
18 Correct 84 ms 6284 KB Output is correct
19 Correct 80 ms 6180 KB Output is correct
20 Correct 124 ms 8708 KB Output is correct
21 Correct 125 ms 8448 KB Output is correct
22 Correct 125 ms 8516 KB Output is correct