답안 #121356

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
121356 2019-06-26T12:14:29 Z MKopchev 자동 인형 (IOI18_doll) C++14
47 / 100
141 ms 9936 KB
#include "doll.h"
#include<bits/stdc++.h>
using namespace std;
/*
void answer(vector<int> C,vector<int> x,vector<int> y)
{
    cout<<"C: ";for(auto k:C)cout<<k<<" ";cout<<endl;
    int SZ=x.size();
    cout<<"switches "<<endl;
    for(int i=0;i<SZ;i++)
    {
        cout<<x[i]<<" "<<y[i]<<endl;
    }
    cout<<"---"<<endl;
    //exit(0);
}
*/
vector<int> x,y;

vector<int> order;

bool state[1'000'000];

int open;

void solve(int run,int where)
{
    //cout<<"solve "<<run<<" "<<where<<endl;
    where=-where;
    if(where>=open/2)
    {
        if(run<order.size())
        {
            if(state[where-1]==0)
            {
                x[where-1]=order[run];
                state[where-1]=!state[where-1];
            }
            else
            {
                y[where-1]=order[run];
                state[where-1]=!state[where-1];
            }
            return;
        }

        if(run==open-1)
        {
            y[where-1]=0;
            return;
        }

        state[where-1]=!state[where-1];
        return;
    }

    if(state[where-1]==0)
    {
        state[where-1]=1;
        solve(run,x[where-1]);
    }
    else
    {
        state[where-1]=0;
        solve(run,y[where-1]);
    }
}
void create_circuit(int M, vector<int> A)
{
    vector<int> C={};
    for(int i=0;i<=M;i++)
        C.push_back(-1);

    C[0]=A[0];

    A.erase(A.begin(),A.begin()+1);

    open=2;
    while(open<=A.size())open=open*2;

    for(int i=1;i<open;i++)
    {
        x.push_back(-1);
        y.push_back(-1);
    }
    for(int i=1;i<open/2;i++)
    {
        x[i-1]=-(2*i);
        y[i-1]=-(2*i+1);
    }
    order=A;

    //answer(C,x,y);

    for(int i=0;i<open;i++)
        solve(i,-1);

    answer(C,x,y);
}
/*
int main()
{
    create_circuit(4, {1, 2, 1,3});
}
*/

Compilation message

doll.cpp: In function 'void solve(int, int)':
doll.cpp:32:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |         if(run<order.size())
      |            ~~~^~~~~~~~~~~~~
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:79:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   79 |     while(open<=A.size())open=open*2;
      |           ~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 2 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 2 ms 204 KB Output is partially correct
2 Correct 68 ms 5288 KB Output is correct
3 Partially correct 115 ms 8308 KB Output is partially correct
4 Partially correct 141 ms 9384 KB Output is partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 2 ms 204 KB Output is partially correct
2 Correct 68 ms 5288 KB Output is correct
3 Partially correct 115 ms 8308 KB Output is partially correct
4 Partially correct 141 ms 9384 KB Output is partially correct
5 Partially correct 138 ms 9936 KB Output is partially correct
6 Partially correct 135 ms 9788 KB Output is partially correct
7 Partially correct 140 ms 9760 KB Output is partially correct
8 Partially correct 130 ms 9588 KB Output is partially correct
9 Partially correct 119 ms 8356 KB Output is partially correct
10 Partially correct 124 ms 9752 KB Output is partially correct
11 Partially correct 135 ms 9252 KB Output is partially correct
12 Partially correct 116 ms 8488 KB Output is partially correct
13 Correct 67 ms 5364 KB Output is correct
14 Partially correct 119 ms 8920 KB Output is partially correct
15 Partially correct 119 ms 8996 KB Output is partially correct
16 Partially correct 4 ms 588 KB Output is partially correct
17 Correct 77 ms 5188 KB Output is correct
18 Correct 81 ms 5220 KB Output is correct
19 Partially correct 119 ms 8532 KB Output is partially correct
20 Partially correct 126 ms 9452 KB Output is partially correct
21 Partially correct 128 ms 9288 KB Output is partially correct
22 Partially correct 123 ms 9276 KB Output is partially correct