답안 #829811

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
829811 2023-08-18T15:10:25 Z vnm06 자동 인형 (IOI18_doll) C++14
100 / 100
87 ms 9576 KB
#include<bits/stdc++.h>
#include "doll.h"
using namespace std;

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

int brn=0;
int ty[1000005];
void dfs(int pos)
{
    while(1)
    {
        ///cout<<pos<<endl;
    if(pos>=0) pos=C[pos];
    else
    {
        if(brn==D.size()) return;
        ty[-pos-1]^=1;
        if(ty[-pos-1]==1)
        {
            if(!X[-pos-1])
            {
                X[-pos-1]=D[brn];
                pos=D[brn];
                brn++;
            }
            else pos=X[-pos-1];
        }
        else
        {
            if(!Y[-pos-1])
            {
                Y[-pos-1]=D[brn];
                pos=D[brn];
                brn++;
            }
            else pos=Y[-pos-1];
        }
    }
    }
}


void create_circuit(int M, std::vector<int> A)
{
    int N = A.size();
    C.resize(M+1);
    for (int i = 0; i <= M; ++i) C[i]=-1;
    D=A;
    int brb=1, n2=N;
    while(n2!=1)
    {
        brb++;
        n2/=2;
    }
    X.resize(N+brb);
    Y.resize(N+brb);
    int tpos=brb+1;
    for(int i=0; i<brb-1; i++)
    {
        int st2=(1<<(brb-i-1));
        if(st2&N)
        {
            X[i]=-tpos;
            Y[i]=-i-2;
            for(int j=tpos; j<tpos+st2/2-1; j++)
            {
                X[j-1]=-(2*(j-tpos+1)+tpos-1);
                Y[j-1]=-(2*(j-tpos+1)+tpos);
            }
            tpos+=st2-1;
        }
        else
        {
            X[i]=-1;
            Y[i]=-i-2;
        }
    }
    if(N%2==0) {X[brb-1]=-1;}
    Y[brb-1]=0;
    dfs(0);
    X.resize(tpos-1);
    Y.resize(tpos-1);
    answer(C, X, Y);
}

Compilation message

doll.cpp: In function 'void dfs(int)':
doll.cpp:18:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |         if(brn==D.size()) return;
      |            ~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 29 ms 4068 KB Output is correct
3 Correct 35 ms 3676 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 7 ms 1492 KB Output is correct
6 Correct 41 ms 5424 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 29 ms 4068 KB Output is correct
3 Correct 35 ms 3676 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 7 ms 1492 KB Output is correct
6 Correct 41 ms 5424 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 62 ms 6336 KB Output is correct
9 Correct 54 ms 6672 KB Output is correct
10 Correct 82 ms 9576 KB Output is correct
11 Correct 0 ms 232 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 29 ms 4068 KB Output is correct
3 Correct 35 ms 3676 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 7 ms 1492 KB Output is correct
6 Correct 41 ms 5424 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 62 ms 6336 KB Output is correct
9 Correct 54 ms 6672 KB Output is correct
10 Correct 82 ms 9576 KB Output is correct
11 Correct 0 ms 232 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 84 ms 9180 KB Output is correct
15 Correct 57 ms 5892 KB Output is correct
16 Correct 82 ms 9104 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 79 ms 9264 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 46 ms 5468 KB Output is correct
3 Correct 45 ms 5468 KB Output is correct
4 Correct 83 ms 8136 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 46 ms 5468 KB Output is correct
3 Correct 45 ms 5468 KB Output is correct
4 Correct 83 ms 8136 KB Output is correct
5 Correct 84 ms 8808 KB Output is correct
6 Correct 87 ms 8624 KB Output is correct
7 Correct 78 ms 8732 KB Output is correct
8 Correct 74 ms 8424 KB Output is correct
9 Correct 46 ms 5472 KB Output is correct
10 Correct 73 ms 8352 KB Output is correct
11 Correct 71 ms 8084 KB Output is correct
12 Correct 46 ms 5460 KB Output is correct
13 Correct 49 ms 5684 KB Output is correct
14 Correct 57 ms 5768 KB Output is correct
15 Correct 50 ms 5952 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 44 ms 5432 KB Output is correct
18 Correct 46 ms 5440 KB Output is correct
19 Correct 45 ms 5464 KB Output is correct
20 Correct 71 ms 8172 KB Output is correct
21 Correct 69 ms 8140 KB Output is correct
22 Correct 69 ms 8084 KB Output is correct