Submission #101904

# Submission time Handle Problem Language Result Execution time Memory
101904 2019-03-21T01:25:00 Z daniel920712 Mechanical Doll (IOI18_doll) C++14
2 / 100
1000 ms 5784 KB
#include "doll.h"
#include <vector>
#include <stdio.h>

using namespace std;
int con[1000005]={0};
int This[1000005]={0};
int m[1000005];
int n[1000005];
int start[1000005]={0};
vector < int > C,x,y;
int X[1000005]={0};
int Y[1000005]={0};
int now=1;
int t[1000005]={0};
int how[1000005]={0};
void build(int N,int here,int a,int b)
{
    if(N==2)
    {
        X[-here]=a;
        Y[-here]=b;
    }
    else if(N%2==0)
    {
        X[-here]=(-now);
        now++;

        Y[-here]=(-now);
        now++;
        build(N/2,X[-here],a,b);
        build(N/2,Y[-here],0,0);
    }
    else
    {
        X[-here]=(-now);
        now++;

        Y[-here]=(-now);
        now++;

        build(N/2+1,X[-here],a,b);
        build(N/2+1,Y[-here],here,0);
    }
    //printf("%d %d %d %d\n",N,here,X[-here],Y[-here]);
}
void New(int here,int what)
{
    if(how[-here]%2)
    {
        how[-here]++;
        if(X[-here]) New(X[here],what);
        else X[-here]=what;
    }
    else
    {
        how[-here]++;
        if(Y[-here]) New(Y[here],what);
        else Y[-here]=what;
    }
}
void create_circuit(int M, vector < int > A)
{
    int N=A.size(),i,temp;
    C.push_back(A[0]);
    for(i=1;i<=M;i++) C.push_back(i);
    for(i=0;i<N;i++) con[A[i]]++;
    A.push_back(0);
    for(i=0;i<N;i++)
    {
        if(con[A[i]]==1)
        {
            C[A[i]]=A[i+1];
        }
        else
        {
            if(!This[A[i]])
            {
                C[A[i]]=-now;
                now++;
                build(con[A[i]],C[A[i]],0,0);

            }
            New(C[A[i]],A[i+1]);
            This[A[i]]++;

        }




    }
    //printf("a %d\n",now-1);
    for(i=1;i<now;i++) x.push_back(X[i]);
    for(i=1;i<now;i++) y.push_back(Y[i]);
    answer(C,x,y);

}

Compilation message

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:64:22: warning: unused variable 'temp' [-Wunused-variable]
   64 |     int N=A.size(),i,temp;
      |                      ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 23 ms 2472 KB Output is correct
3 Correct 22 ms 1980 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 13 ms 1808 KB Output is correct
6 Correct 28 ms 2852 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 23 ms 2472 KB Output is correct
3 Correct 22 ms 1980 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 13 ms 1808 KB Output is correct
6 Correct 28 ms 2852 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Incorrect 56 ms 5784 KB wrong motion
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 23 ms 2472 KB Output is correct
3 Correct 22 ms 1980 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 13 ms 1808 KB Output is correct
6 Correct 28 ms 2852 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Incorrect 56 ms 5784 KB wrong motion
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1082 ms 204 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1070 ms 204 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1070 ms 204 KB Time limit exceeded
2 Halted 0 ms 0 KB -