답안 #1076902

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1076902 2024-08-26T18:31:32 Z belgianbot 자동 인형 (IOI18_doll) C++17
6 / 100
54 ms 14900 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 build(int x) {
    int n = adj[x].size();
    if (n == 1) C[x] = adj[x][0];
    else if (n) {
        C[x] = cnt; cnt--;
        for (int i = n - 1; i > 0; i--) {
            Y.pb(0);
            int first = cnt + 1;
            int time = i - 1;
            pair<int,int> act = {0, 0}, pre = {1, cnt + 1};
            while (time) {
                if (time % pre.fi == 0) {
                    time -= pre.fi;
                    Y.pb(pre.se);
                    X.pb(cnt);
                    act = {pre.fi, cnt};
                    pre.fi *= 2;
                    cnt--;
                }
                else {
                    time -= act.fi;
                    Y.pb(act.se);
                    X.pb(cnt);
                    pre = {act.fi * 2, act.se};
                    act.se = cnt;
                    cnt--;
                }
            }
            X.pb(adj[x][n - 1 - i]);
            auto it = Y.end() + (cnt - first);
            if (i != 1) {
                *it = cnt;
                cnt--;
            }
            else *it = adj[x].back();

        }
    }
    else {
        C[x] = 0;
    }

} 
void create_circuit(int M, vector<int> A) {
    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);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 17 ms 6996 KB Output is correct
3 Correct 14 ms 5720 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 8 ms 3760 KB Output is correct
6 Correct 22 ms 8524 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 17 ms 6996 KB Output is correct
3 Correct 14 ms 5720 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 8 ms 3760 KB Output is correct
6 Correct 22 ms 8524 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 34 ms 9036 KB Output is correct
9 Correct 31 ms 10068 KB Output is correct
10 Correct 43 ms 13880 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 17 ms 6996 KB Output is correct
3 Correct 14 ms 5720 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 8 ms 3760 KB Output is correct
6 Correct 22 ms 8524 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 34 ms 9036 KB Output is correct
9 Correct 31 ms 10068 KB Output is correct
10 Correct 43 ms 13880 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 54 ms 14900 KB Output is correct
15 Incorrect 40 ms 10092 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -