Submission #829496

# Submission time Handle Problem Language Result Execution time Memory
829496 2023-08-18T11:32:18 Z vnm06 Mechanical Doll (IOI18_doll) C++14
47 / 100
69 ms 10820 KB
#include<bits/stdc++.h>
#include "doll.h"
using namespace std;

bool st2(int n)
{
    return n==(n&(-n));
}

vector<int> C;
vector<int> posl;
vector<int> posl2;

void merge_posl(int le, int ri)
{
    if(le==ri) return;
    int mid=(le+ri)/2;
    merge_posl(le, mid);
    merge_posl(mid+1, ri);
    posl2.resize(ri-le+1);
    for(int i=0; i<ri-le+1; i++)
    {
        if(i%2==0) posl2[i]=posl[le+i/2];
        else posl2[i]=posl[mid+1+i/2];
    }
    for(int i=le; i<=ri; i++) posl[i]=posl2[i-le];
}

void create_circuit(int M, std::vector<int> A)
{
    C.resize(M+1);
    for (int i = 0; i <= M; ++i) C[i]=-1;
    C[0]=A[0];
    int N = A.size();
    for(int i=0; i<N-1; i++) A[i]=A[i+1];
    A.resize(N-1);
    N--;
    while(!st2(N+1))
    {
        N++;
        A.push_back(-1);
    }
    A.push_back(0);

    std::vector<int> X(N), Y(N);
    for (int k = 1; k <= N/2; k++)
    {
        X[k-1]=-2*k;
        Y[k-1]=-2*k-1;
    }
    int rm=1, le=1, ri=1;
    posl=A;
    merge_posl(0, N-1);
    /**
    while(rm!=N+1)
    {
        rm*=2;
        posl2.resize(rm);
        for(int i=0; i<rm; i++)
        {
            if(i%2==0) posl2[i]=posl[i/2];
            else posl2[i]=A[le+i/2];
        }
        le=ri+1;
        ri=le*2-1;
        posl=posl2;
        for(int i=0; i<posl.size(); i++) cout<<posl[i]<<" ";
        cout<<endl;
    }*/
    for (int k = N/2+1; k <=N; k++)
    {
        X[k-1]=posl[2*(k-N/2-1)];
        Y[k-1]=posl[2*(k-N/2-1)+1];
    }
   /// cout<<N<<endl;
  ///  for(int i=0; i<=M; i++) cout<<C[i]<<" ";
  ///  cout<<endl;
 ///  for(int i=0; i<N; i++) cout<<X[i]<<" "<<Y[i]<<endl;
    answer(C, X, Y);
}

Compilation message

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:51:9: warning: unused variable 'rm' [-Wunused-variable]
   51 |     int rm=1, le=1, ri=1;
      |         ^~
doll.cpp:51:15: warning: unused variable 'le' [-Wunused-variable]
   51 |     int rm=1, le=1, ri=1;
      |               ^~
doll.cpp:51:21: warning: unused variable 'ri' [-Wunused-variable]
   51 |     int rm=1, le=1, ri=1;
      |                     ^~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
3 Correct 0 ms 296 KB Output is correct
4 Correct 1 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 1 ms 300 KB Output is correct
8 Correct 1 ms 224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 212 KB Output is partially correct
2 Correct 30 ms 5552 KB Output is correct
3 Partially correct 52 ms 10144 KB Output is partially correct
4 Partially correct 58 ms 10288 KB Output is partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 212 KB Output is partially correct
2 Correct 30 ms 5552 KB Output is correct
3 Partially correct 52 ms 10144 KB Output is partially correct
4 Partially correct 58 ms 10288 KB Output is partially correct
5 Partially correct 62 ms 10820 KB Output is partially correct
6 Partially correct 61 ms 10532 KB Output is partially correct
7 Partially correct 61 ms 10692 KB Output is partially correct
8 Partially correct 62 ms 10412 KB Output is partially correct
9 Partially correct 52 ms 10156 KB Output is partially correct
10 Partially correct 59 ms 10436 KB Output is partially correct
11 Partially correct 58 ms 10324 KB Output is partially correct
12 Partially correct 53 ms 10144 KB Output is partially correct
13 Correct 33 ms 5580 KB Output is correct
14 Partially correct 69 ms 10260 KB Output is partially correct
15 Partially correct 55 ms 10296 KB Output is partially correct
16 Partially correct 2 ms 596 KB Output is partially correct
17 Correct 31 ms 6808 KB Output is correct
18 Correct 31 ms 5580 KB Output is correct
19 Partially correct 53 ms 10196 KB Output is partially correct
20 Partially correct 59 ms 10296 KB Output is partially correct
21 Partially correct 59 ms 10324 KB Output is partially correct
22 Partially correct 58 ms 10308 KB Output is partially correct