Submission #829754

# Submission time Handle Problem Language Result Execution time Memory
829754 2023-08-18T14:47:15 Z bachhoangxuan Mechanical Doll (IOI18_doll) C++17
100 / 100
124 ms 11084 KB
#include "doll.h"
#include <bits/stdc++.h>
using namespace std;
const int maxn=3e5+5;


void create_circuit(int M, std::vector<int> A) {
    vector<int> s(M+1,-1),x(maxn,0),y(maxn,0),z(maxn,0);
    A.push_back(0);
    int n=(int)A.size(),sz=1,cnt=0;
    while(sz<n) sz*=2;

    function<int(int,int)> dnc = [&](int l,int r){
        if(l>=n) return -1;
        if(r-l>1){
            int mid=(l+r)>>1,u=cnt++;
            y[u]=dnc(l,mid);x[u]=dnc(mid,r);
            return -(u+1);
        }
        return 1;
    };
    dnc(0,sz);

    for(int i:A){
        int u=0;
        while(u>=0){
            z[u]^=1;
            int &w = z[u]?x[u]:y[u];
            if(w>=0){w=i;break;}
            else u=-1-w;
        }
    }
    x.resize(cnt);
    y.resize(cnt);
    answer(s,x,y);
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3752 KB Output is correct
2 Correct 40 ms 6980 KB Output is correct
3 Correct 39 ms 6512 KB Output is correct
4 Correct 2 ms 3796 KB Output is correct
5 Correct 9 ms 4948 KB Output is correct
6 Correct 59 ms 7916 KB Output is correct
7 Correct 2 ms 3796 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3752 KB Output is correct
2 Correct 40 ms 6980 KB Output is correct
3 Correct 39 ms 6512 KB Output is correct
4 Correct 2 ms 3796 KB Output is correct
5 Correct 9 ms 4948 KB Output is correct
6 Correct 59 ms 7916 KB Output is correct
7 Correct 2 ms 3796 KB Output is correct
8 Correct 72 ms 8592 KB Output is correct
9 Correct 82 ms 8984 KB Output is correct
10 Correct 115 ms 11084 KB Output is correct
11 Correct 2 ms 3752 KB Output is correct
12 Correct 2 ms 3796 KB Output is correct
13 Correct 2 ms 3796 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3752 KB Output is correct
2 Correct 40 ms 6980 KB Output is correct
3 Correct 39 ms 6512 KB Output is correct
4 Correct 2 ms 3796 KB Output is correct
5 Correct 9 ms 4948 KB Output is correct
6 Correct 59 ms 7916 KB Output is correct
7 Correct 2 ms 3796 KB Output is correct
8 Correct 72 ms 8592 KB Output is correct
9 Correct 82 ms 8984 KB Output is correct
10 Correct 115 ms 11084 KB Output is correct
11 Correct 2 ms 3752 KB Output is correct
12 Correct 2 ms 3796 KB Output is correct
13 Correct 2 ms 3796 KB Output is correct
14 Correct 124 ms 10696 KB Output is correct
15 Correct 69 ms 8212 KB Output is correct
16 Correct 102 ms 10504 KB Output is correct
17 Correct 2 ms 3796 KB Output is correct
18 Correct 3 ms 3760 KB Output is correct
19 Correct 2 ms 3796 KB Output is correct
20 Correct 106 ms 10888 KB Output is correct
21 Correct 2 ms 3796 KB Output is correct
22 Correct 2 ms 3796 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3796 KB Output is correct
2 Correct 2 ms 3796 KB Output is correct
3 Correct 2 ms 3796 KB Output is correct
4 Correct 2 ms 3796 KB Output is correct
5 Correct 2 ms 3796 KB Output is correct
6 Correct 2 ms 3796 KB Output is correct
7 Correct 2 ms 3752 KB Output is correct
8 Correct 2 ms 3796 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3760 KB Output is correct
2 Correct 67 ms 7704 KB Output is correct
3 Correct 74 ms 7824 KB Output is correct
4 Correct 102 ms 9928 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3760 KB Output is correct
2 Correct 67 ms 7704 KB Output is correct
3 Correct 74 ms 7824 KB Output is correct
4 Correct 102 ms 9928 KB Output is correct
5 Correct 103 ms 10340 KB Output is correct
6 Correct 108 ms 10132 KB Output is correct
7 Correct 102 ms 10292 KB Output is correct
8 Correct 102 ms 10092 KB Output is correct
9 Correct 68 ms 7820 KB Output is correct
10 Correct 102 ms 9960 KB Output is correct
11 Correct 101 ms 9880 KB Output is correct
12 Correct 64 ms 7828 KB Output is correct
13 Correct 66 ms 7964 KB Output is correct
14 Correct 69 ms 7968 KB Output is correct
15 Correct 68 ms 8060 KB Output is correct
16 Correct 3 ms 3924 KB Output is correct
17 Correct 62 ms 7824 KB Output is correct
18 Correct 63 ms 7700 KB Output is correct
19 Correct 67 ms 7880 KB Output is correct
20 Correct 100 ms 9928 KB Output is correct
21 Correct 101 ms 9924 KB Output is correct
22 Correct 103 ms 10044 KB Output is correct