답안 #983661

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
983661 2024-05-15T21:54:47 Z mariaclara 자동 인형 (IOI18_doll) C++17
10 / 100
82 ms 8512 KB
#include "doll.h"
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
const int MAXN = 4e5+5; 
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define mk make_pair
#define pb push_back
#define fr first
#define sc second

int N;
vector<int> ans, S_x, S_y, state;
int create(int qnt) {
    if(qnt == 1) return 1;
    int a = create(qnt/2), b = create(qnt/2);
    S_x.pb(a);
    S_y.pb(b);
    return -sz(S_y);
}

void create_circuit(int M, vector<int> A) {
    A.pb(0);
    N = sz(A);
    
    vector<int> pot;
    for(int i = 20; i >= 0; i--)
        if(N >= (1<<i)) pot.pb(i), N -= (1<<i);

    N = sz(A);

    reverse(all(pot));

    for(int i = 0, last = 0; i < sz(pot); i++) {
        int k = create((1<<pot[i]));
        if(i > 0) {
            S_x.pb(k);
            S_y.pb(last);
        }
        if(i == sz(pot)-1) break;
        int add = pot[i+1] - pot[i] - !!i;
        while(add--) {
            S_y.pb(k);
            S_x.pb(-sz(S_y));
            k = -sz(S_x);
        }
        last = -sz(S_x);
    }

    int S = sz(S_x);
    vector<int> ans(M+1, -S), state(S);

    for(int i = 0; i < S; i++)
        if(S_x[i] == -i-1) S_x[i] = -S;

    // for(int i = 0; i < S; i++)
    //     cout << S_x[i] << " " << S_y[i] << endl;

    int x = -S, qtd = 0;
    while(qtd < N) {
        if(state[-x-1] == 0) {
            state[-x-1] = 1;
            if(S_x[-x-1] == 1) S_x[-x-1] = A[qtd], qtd++, x = -S;
            else x = S_x[-x-1]; 
        } 
        else {
            state[-x-1] = 0;
            if(S_y[-x-1] == 1) S_y[-x-1] = A[qtd], qtd++, x = -S;
            else x = S_y[-x-1]; 
        }
    }

    return answer(ans, S_x, S_y);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 33 ms 5068 KB Output is correct
3 Correct 30 ms 4692 KB Output is correct
4 Correct 1 ms 504 KB Output is correct
5 Correct 8 ms 1372 KB Output is correct
6 Runtime error 22 ms 5588 KB Execution killed with signal 11
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 33 ms 5068 KB Output is correct
3 Correct 30 ms 4692 KB Output is correct
4 Correct 1 ms 504 KB Output is correct
5 Correct 8 ms 1372 KB Output is correct
6 Runtime error 22 ms 5588 KB Execution killed with signal 11
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 33 ms 5068 KB Output is correct
3 Correct 30 ms 4692 KB Output is correct
4 Correct 1 ms 504 KB Output is correct
5 Correct 8 ms 1372 KB Output is correct
6 Runtime error 22 ms 5588 KB Execution killed with signal 11
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 54 ms 5580 KB Output is correct
3 Correct 60 ms 5568 KB Output is correct
4 Incorrect 82 ms 8512 KB state 'Y'
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 54 ms 5580 KB Output is correct
3 Correct 60 ms 5568 KB Output is correct
4 Incorrect 82 ms 8512 KB state 'Y'
5 Halted 0 ms 0 KB -