답안 #595383

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
595383 2022-07-13T17:01:46 Z mosiashvililuka 자동 인형 (IOI18_doll) C++14
100 / 100
124 ms 15204 KB
#include<bits/stdc++.h>
#include "doll.h"
using namespace std;
const int N=-400009;
int a,b,c,d,e,i,j,ii,jj,zx,xc,f[200009],pi,za,lf[400009],rg[400009],rt,BOlf[400009],BOrg[400009],sw[400009],co,SIZ,l,r;
vector <int> C,X,Y,v;
bool chk(int q, int w){
    if(q>r||w<l) return 0; else return 1;
}
void rec(int q, int w, int rr){
    int mid=(q+w)/2;
    if(q==mid){
        if(chk(q,mid)==1){
            BOlf[rr]=1;
            lf[rr]=-1;
        }else{
            lf[rr]=-1;
        }
    }else{
        if(chk(q,mid)==1){
            pi++;lf[rr]=pi;
            rec(q,mid,lf[rr]);
        }else{
            lf[rr]=-1;
        }
    }
    if(mid+1==w){
        if(chk(mid+1,w)==1){
            BOrg[rr]=1;
            rg[rr]=-1;
        }else{
            rg[rr]=-1;
        }
    }else{
        if(chk(mid+1,w)==1){
            pi++;rg[rr]=pi;
            rec(mid+1,w,rg[rr]);
        }else{
            rg[rr]=-1;
        }
    }
}
void dfs(int rr){
    if(xc>=SIZ) return;
    if(sw[rr]==0){

    sw[rr]=1;
    if(lf[rr]!=-1){
        dfs(lf[rr]);
    }else{
        if(BOlf[rr]==0){
            lf[rr]=rt;
        }else{
            lf[rr]=v[xc];xc++;
        }
        dfs(rt);
    }

    return;
    }

    sw[rr]=0;
    if(rg[rr]!=-1){
        dfs(rg[rr]);
    }else{
        if(BOrg[rr]==0){
            rg[rr]=rt;
        }else{
            rg[rr]=v[xc];xc++;
        }
        dfs(rt);
    }
}
void create_circuit(int MM, std::vector<int> AA) {
    a=AA.size();b=MM;
    for(i=1; i<=a; i++) f[i]=AA[i-1];
    C.resize(b+1);pi=0;
    for(i=1; i<=a; i++){
        v.push_back(f[i]);
    }
    v.push_back(0);
    for(i=0; i<=b; i++) C[i]=-1;
    //
        SIZ=v.size();
        za=1;
        while(za<SIZ) za*=2;

        l=za-SIZ+1;r=za;
        pi++;rt=pi;
        rec(1,za,rt);
        //zx=za-SIZ;xc=0;
        xc=0;
        dfs(rt);
    //
    X.resize(pi);Y.resize(pi);
    for(i=1; i<=pi; i++){
        if(BOlf[i]==1) X[i-1]=lf[i]; else X[i-1]=-lf[i];
        if(BOrg[i]==1) Y[i-1]=rg[i]; else Y[i-1]=-rg[i];
    }
    answer(C,X,Y);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 37 ms 6188 KB Output is correct
3 Correct 35 ms 6080 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 11 ms 1492 KB Output is correct
6 Correct 56 ms 8152 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 37 ms 6188 KB Output is correct
3 Correct 35 ms 6080 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 11 ms 1492 KB Output is correct
6 Correct 56 ms 8152 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 66 ms 11028 KB Output is correct
9 Correct 81 ms 11592 KB Output is correct
10 Correct 112 ms 15204 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 37 ms 6188 KB Output is correct
3 Correct 35 ms 6080 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 11 ms 1492 KB Output is correct
6 Correct 56 ms 8152 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 66 ms 11028 KB Output is correct
9 Correct 81 ms 11592 KB Output is correct
10 Correct 112 ms 15204 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 101 ms 14644 KB Output is correct
15 Correct 80 ms 10620 KB Output is correct
16 Correct 105 ms 14384 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 312 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 106 ms 14872 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 304 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 316 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 316 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 312 KB Output is correct
2 Correct 72 ms 9632 KB Output is correct
3 Correct 68 ms 9560 KB Output is correct
4 Correct 114 ms 13120 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 312 KB Output is correct
2 Correct 72 ms 9632 KB Output is correct
3 Correct 68 ms 9560 KB Output is correct
4 Correct 114 ms 13120 KB Output is correct
5 Correct 106 ms 14272 KB Output is correct
6 Correct 102 ms 13576 KB Output is correct
7 Correct 109 ms 14024 KB Output is correct
8 Correct 112 ms 13712 KB Output is correct
9 Correct 60 ms 9624 KB Output is correct
10 Correct 101 ms 13688 KB Output is correct
11 Correct 103 ms 13212 KB Output is correct
12 Correct 62 ms 9868 KB Output is correct
13 Correct 73 ms 10252 KB Output is correct
14 Correct 66 ms 10300 KB Output is correct
15 Correct 70 ms 10424 KB Output is correct
16 Correct 4 ms 596 KB Output is correct
17 Correct 73 ms 9044 KB Output is correct
18 Correct 62 ms 9852 KB Output is correct
19 Correct 60 ms 9788 KB Output is correct
20 Correct 93 ms 13572 KB Output is correct
21 Correct 124 ms 13448 KB Output is correct
22 Correct 95 ms 13500 KB Output is correct