답안 #1078307

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1078307 2024-08-27T15:07:48 Z belgianbot 자동 인형 (IOI18_doll) C++17
53 / 100
88 ms 17288 KB
#include "doll.h"
#include <bits/stdc++.h>
#define pb push_back
#define fi first 
#define se second

using namespace std;

vector<vector<int>> adj;
vector<int> C, X, Y;

int cnt = -1;

void divide(vector<int> *a, int prev) {
    if (a->size() == 2) {
        X.pb((*a)[0]);
        Y.pb((*a)[1]);
        return;
    }

    vector<int> b, c;
    for (int i = 0; i < a->size(); i++) {
        if (i & 1) c.pb( (*a)[i]);
        else b.pb((*a)[i]);
    }
    if (b.size() > c.size()) {
        c.pb(b.back());
        b.back() = prev;
    }
    X.pb(cnt); cnt--; Y.pb(0); int n = Y.size();
    divide(&b, cnt + 1);
    Y[n - 1] = cnt; cnt--;
    divide(&c, cnt + 1);
}
void build(int x) {
    int n = adj[x].size();
    if (!n) adj[x].pb(x);
    if (n == 1) C[x] = adj[x][0];
    else if (n) {
        C[x] = cnt; cnt--;
        divide(&adj[x], cnt + 1);
    }

} 
void create_circuit(int M, vector<int> A) {
    /*if (M == 1) {
            int N = A.size();
    A.push_back(0);
    vector<int> C(M + 1, INT_MAX), X, Y;
    C[0] = A[0];
 
    int time = N - 1;
    vector<pair<int,int>> fact = {{1, 1}};
    int cnt = -1;
    while (time) {
        int next = 0;
        for (auto x : fact) {
            if (time % x.first == 0) {
                time -= x.first;
                next = x.first;
                X.push_back(x.second);
                if (cnt != -1) Y.push_back(cnt);
                else C[1] = cnt;
                cnt--;
                break;
            }
        }
        for (auto &x : fact) x.first += next;
        fact.push_back({next, cnt + 1});
    }
    if (cnt != -1) Y.push_back(0);
    else C[1] = 0;
    answer(C, X, Y);
    return;
    }*/
    int N = A.size();
    A.push_back(0);
    C.resize(M + 1);

    adj.resize(M + 1);
    adj[0].pb(A[0]); C[0] = A[0];
    for (int i = 1; i <= N; i++) adj[A[i-1]].pb(A[i]);

    for (int i = 1; i <= M; i++) build(i);

    answer(C, X, Y);
}

Compilation message

doll.cpp: In function 'void divide(std::vector<int>*, int)':
doll.cpp:22:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     for (int i = 0; i < a->size(); i++) {
      |                     ~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 18 ms 8024 KB Output is correct
3 Correct 15 ms 5720 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 10 ms 7004 KB Output is correct
6 Correct 21 ms 8512 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 18 ms 8024 KB Output is correct
3 Correct 15 ms 5720 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 10 ms 7004 KB Output is correct
6 Correct 21 ms 8512 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 29 ms 8788 KB Output is correct
9 Correct 32 ms 10412 KB Output is correct
10 Correct 48 ms 13360 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 18 ms 8024 KB Output is correct
3 Correct 15 ms 5720 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 10 ms 7004 KB Output is correct
6 Correct 21 ms 8512 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 29 ms 8788 KB Output is correct
9 Correct 32 ms 10412 KB Output is correct
10 Correct 48 ms 13360 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 82 ms 14388 KB Output is correct
15 Correct 35 ms 7796 KB Output is correct
16 Correct 45 ms 11312 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 53 ms 13476 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 348 KB Output is partially correct
2 Correct 34 ms 7748 KB Output is correct
3 Partially correct 57 ms 12100 KB Output is partially correct
4 Partially correct 69 ms 12596 KB Output is partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 348 KB Output is partially correct
2 Correct 34 ms 7748 KB Output is correct
3 Partially correct 57 ms 12100 KB Output is partially correct
4 Partially correct 69 ms 12596 KB Output is partially correct
5 Partially correct 70 ms 15540 KB Output is partially correct
6 Partially correct 88 ms 16396 KB Output is partially correct
7 Partially correct 77 ms 16136 KB Output is partially correct
8 Partially correct 83 ms 16788 KB Output is partially correct
9 Partially correct 58 ms 10620 KB Output is partially correct
10 Partially correct 86 ms 15548 KB Output is partially correct
11 Partially correct 87 ms 17288 KB Output is partially correct
12 Partially correct 60 ms 10364 KB Output is partially correct
13 Partially correct 50 ms 9924 KB Output is partially correct
14 Partially correct 62 ms 9964 KB Output is partially correct
15 Partially correct 47 ms 9656 KB Output is partially correct
16 Partially correct 3 ms 1112 KB Output is partially correct
17 Partially correct 48 ms 8276 KB Output is partially correct
18 Partially correct 48 ms 8400 KB Output is partially correct
19 Partially correct 49 ms 8908 KB Output is partially correct
20 Partially correct 75 ms 12556 KB Output is partially correct
21 Partially correct 75 ms 15160 KB Output is partially correct
22 Partially correct 61 ms 11688 KB Output is partially correct