답안 #775636

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
775636 2023-07-06T16:39:47 Z GusterGoose27 자동 인형 (IOI18_doll) C++17
84 / 100
123 ms 262144 KB
#include "doll.h"

#include <bits/stdc++.h>

using namespace std;

int n, m;
vector<int> x, y;

int t = 0;

void make(int n, int f) {
    if (f == 2) {
        if (n == 2) {
            x.push_back(0);
            y.push_back(0);
        }
        else {
            x.push_back(-1);
            y.push_back(0);
        }
        t++;
        return;
    }
    if (n <= f/2) {
        x.push_back(-1);
        t++;
        y.push_back(-t);
        make(n, f/2);
    }
    else {
        t++;
        int l_size = n-f/2;
        x.push_back(-t);
        y.push_back(0);
        int uv = y.size()-1;
        make(l_size, f/2);
        y[uv] = -t;
        make(f/2, f/2);
    }
    return;
}

vector<int> state;

void sim(int cur, int tar) {
    int nxt;
    if (state[cur] == 0) {
        nxt = -x[cur-1];
    }
    else nxt = -y[cur-1];
    if (nxt == 0) {
        if (state[cur] == 0) x[cur-1] = tar;
        else y[cur-1] = tar;
    }
    state[cur] = 1-state[cur];
    if (nxt != 0) sim(nxt, tar);
}

void create_circuit(int M, vector<int> A) {
    n = A.size();
    m = M;
    vector<int> C(M + 1);
    fill(C.begin(), C.end(), -1);
    C[0] = A[0];
    vector<int> nvals;
    for (int i = 1; i < n; i++) nvals.push_back(A[i]);
    nvals.push_back(0);
    int f = 1;
    while (f < n) f *= 2; t++;
    make(n, f);
    state = vector<int>(t); assert(t == x.size()+1);
    fill(state.begin(), state.end(), 0);
    for (int i = 0; i < n; i++) sim(1, nvals[i]);
    answer(C, x, y);
    // for (int i = 0; i < x.size(); i++) cout << x[i] << ' ' << y[i] << "\n";
}

Compilation message

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:70:5: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
   70 |     while (f < n) f *= 2; t++;
      |     ^~~~~
doll.cpp:70:27: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
   70 |     while (f < n) f *= 2; t++;
      |                           ^
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from doll.cpp:3:
doll.cpp:72:38: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |     state = vector<int>(t); assert(t == x.size()+1);
      |                                    ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 30 ms 4220 KB Output is correct
3 Correct 29 ms 4280 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 7 ms 1364 KB Output is correct
6 Correct 57 ms 5600 KB Output is correct
7 Runtime error 123 ms 262144 KB Execution killed with signal 9
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 30 ms 4220 KB Output is correct
3 Correct 29 ms 4280 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 7 ms 1364 KB Output is correct
6 Correct 57 ms 5600 KB Output is correct
7 Runtime error 123 ms 262144 KB Execution killed with signal 9
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 30 ms 4220 KB Output is correct
3 Correct 29 ms 4280 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 7 ms 1364 KB Output is correct
6 Correct 57 ms 5600 KB Output is correct
7 Runtime error 123 ms 262144 KB Execution killed with signal 9
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 296 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 52 ms 5924 KB Output is correct
3 Correct 57 ms 5696 KB Output is correct
4 Correct 85 ms 8396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 52 ms 5924 KB Output is correct
3 Correct 57 ms 5696 KB Output is correct
4 Correct 85 ms 8396 KB Output is correct
5 Correct 93 ms 8660 KB Output is correct
6 Correct 101 ms 8504 KB Output is correct
7 Correct 103 ms 8540 KB Output is correct
8 Correct 87 ms 8388 KB Output is correct
9 Correct 54 ms 5732 KB Output is correct
10 Correct 93 ms 8416 KB Output is correct
11 Correct 85 ms 8340 KB Output is correct
12 Correct 56 ms 5952 KB Output is correct
13 Correct 56 ms 5956 KB Output is correct
14 Correct 56 ms 6460 KB Output is correct
15 Correct 63 ms 6564 KB Output is correct
16 Correct 2 ms 468 KB Output is correct
17 Correct 53 ms 5908 KB Output is correct
18 Correct 51 ms 5916 KB Output is correct
19 Correct 52 ms 5944 KB Output is correct
20 Correct 87 ms 8300 KB Output is correct
21 Correct 85 ms 8336 KB Output is correct
22 Correct 85 ms 8416 KB Output is correct