Submission #1096441

# Submission time Handle Problem Language Result Execution time Memory
1096441 2024-10-04T12:47:25 Z guagua0407 Mechanical Doll (IOI18_doll) C++17
54.4023 / 100
229 ms 26632 KB
#include "doll.h"
//#include "grader.cpp"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int inf=1e9;

void create_circuit(int m, std::vector<int> a) {
    int n=a.size();
    int lg=__lg(n-1)+1;
    vector<int> state(1<<lg);
    vector<vector<int>> to(1<<lg,vector<int>(2,inf));
    for(int i=1;i<(1<<lg);i++){
        if(i*2<(1<<lg)) to[i][0]=-(i*2);
        if(i*2+1<(1<<lg)) to[i][1]=-(i*2+1);
    }
    int diaob=(n)/2;
    for(int i=0;i<diaob;i++){
        int nxt=a[i+1];
        int cur=1;
        while(to[cur][state[cur]]!=inf){
            state[cur]^=1;
            cur=-to[cur][state[cur]^1];
        }
        to[cur][state[cur]]=nxt;
        state[cur]^=1;
    }
    for(int i=diaob;i<(1<<lg);i++){
        int nxt=((i==(1<<lg)-1)?0:(diaob<n-1?a[diaob+1]:-1));
        int cur=1;
        while(to[cur][state[cur]]!=inf){
            state[cur]^=1;
            cur=-to[cur][state[cur]^1];
        }
        if(nxt==0 or (nxt!=-1 and to[cur][state[cur]^1]!=inf)){
            to[cur][state[cur]]=nxt;
            state[cur]^=1;
            diaob++;
        }
        else{
            to[cur][state[cur]]=-1;
            state[cur]^=1;
        }
    }
    vector<int> vec;
    for(int i=1;i<(1<<lg);i++){
        if(to[i][0]!=-1 or to[i][1]!=-1){
            vec.push_back(i);
        }
    }
    vector<int> c(m+1,-1);
    c[0]=a[0];
    vector<int> x(vec.size()),y(vec.size());
    vector<int> id(1<<lg,inf);
    for(int i=0;i<(int)vec.size();i++){
        id[vec[i]]=i+1;
    }
    for(int i=1;i<(1<<lg);i++){
        if(id[i]==inf){
            to[i/2][i-(i/2)*2]=((to[i][0]==-1)?to[i][1]:to[i][0]);
        }
    }
    for(int i=0;i<(int)vec.size();i++){
        x[i]=to[vec[i]][0];
        y[i]=to[vec[i]][1];
        if(x[i]<0) x[i]=-id[-x[i]];
        if(y[i]<0) y[i]=-id[-y[i]];
        if(x[i]==0) swap(x[i],y[i]);
    }
    answer(c,x,y);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 39 ms 8416 KB Output is correct
3 Incorrect 71 ms 13000 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 39 ms 8416 KB Output is correct
3 Incorrect 71 ms 13000 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 39 ms 8416 KB Output is correct
3 Incorrect 71 ms 13000 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 376 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 348 KB Output is partially correct
2 Correct 82 ms 14304 KB Output is correct
3 Partially correct 184 ms 24296 KB Output is partially correct
4 Partially correct 175 ms 26312 KB Output is partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 348 KB Output is partially correct
2 Correct 82 ms 14304 KB Output is correct
3 Partially correct 184 ms 24296 KB Output is partially correct
4 Partially correct 175 ms 26312 KB Output is partially correct
5 Partially correct 189 ms 26632 KB Output is partially correct
6 Partially correct 183 ms 26352 KB Output is partially correct
7 Partially correct 195 ms 26540 KB Output is partially correct
8 Partially correct 210 ms 26312 KB Output is partially correct
9 Partially correct 159 ms 24264 KB Output is partially correct
10 Partially correct 211 ms 26312 KB Output is partially correct
11 Partially correct 188 ms 26308 KB Output is partially correct
12 Partially correct 192 ms 24260 KB Output is partially correct
13 Correct 84 ms 14296 KB Output is correct
14 Partially correct 217 ms 24460 KB Output is partially correct
15 Partially correct 214 ms 24316 KB Output is partially correct
16 Partially correct 2 ms 1112 KB Output is partially correct
17 Correct 83 ms 14360 KB Output is correct
18 Correct 82 ms 14284 KB Output is correct
19 Partially correct 171 ms 24268 KB Output is partially correct
20 Partially correct 229 ms 26344 KB Output is partially correct
21 Partially correct 213 ms 26272 KB Output is partially correct
22 Partially correct 225 ms 26148 KB Output is partially correct