Submission #526360

# Submission time Handle Problem Language Result Execution time Memory
526360 2022-02-14T13:21:58 Z lkh3happy Mechanical Doll (IOI18_doll) C++17
100 / 100
108 ms 14596 KB
#include "doll.h"
#include <bits/stdc++.h>
using namespace std;

int idx[800001], dir[800001], cnt, a;
vector<int> c, x, y;

void create_circuit(int m, vector<int> A){
    c.push_back(A[0]);
    int n=A.size(), k=1;
    A.push_back(0);
    for(int i=1;i<=m;i++) c.push_back(-1+(n==1));
    while(k<n) k*=2;
    for(int i=k;i<k+k-n;i++) idx[i]=-1;
    for(int i=k-1;i>0;i--) idx[i]=(idx[i*2]+idx[i*2+1])/2;
    for(int i=1;i<=n;i++, a=0){
        while(a<k-n+k) for(a=1;a<k;dir[a]^=1, a=a*2+(dir[a]^1));
        idx[a]=A[i];
    }
    for(int i=1;i<k;i++) if(!idx[i]) idx[i]=--cnt;
    x.resize(-cnt); y.resize(-cnt);
    for(int i=1;i<k;i++) if(i==1 || idx[i]+1) x[-idx[i]-1]=idx[i*2], y[-idx[i]-1]=idx[i*2+1];
    answer(c, x, y);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 32 ms 5248 KB Output is correct
3 Correct 34 ms 5808 KB Output is correct
4 Correct 0 ms 308 KB Output is correct
5 Correct 11 ms 1604 KB Output is correct
6 Correct 53 ms 7956 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 32 ms 5248 KB Output is correct
3 Correct 34 ms 5808 KB Output is correct
4 Correct 0 ms 308 KB Output is correct
5 Correct 11 ms 1604 KB Output is correct
6 Correct 53 ms 7956 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 69 ms 9252 KB Output is correct
9 Correct 72 ms 11180 KB Output is correct
10 Correct 107 ms 14596 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 32 ms 5248 KB Output is correct
3 Correct 34 ms 5808 KB Output is correct
4 Correct 0 ms 308 KB Output is correct
5 Correct 11 ms 1604 KB Output is correct
6 Correct 53 ms 7956 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 69 ms 9252 KB Output is correct
9 Correct 72 ms 11180 KB Output is correct
10 Correct 107 ms 14596 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 108 ms 14176 KB Output is correct
15 Correct 68 ms 10092 KB Output is correct
16 Correct 93 ms 13700 KB Output is correct
17 Correct 1 ms 304 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 94 ms 14336 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 1 ms 296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 304 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 300 KB Output is correct
2 Correct 48 ms 7436 KB Output is correct
3 Correct 74 ms 8988 KB Output is correct
4 Correct 89 ms 12344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 300 KB Output is correct
2 Correct 48 ms 7436 KB Output is correct
3 Correct 74 ms 8988 KB Output is correct
4 Correct 89 ms 12344 KB Output is correct
5 Correct 90 ms 13592 KB Output is correct
6 Correct 94 ms 13248 KB Output is correct
7 Correct 94 ms 13300 KB Output is correct
8 Correct 84 ms 12940 KB Output is correct
9 Correct 83 ms 9000 KB Output is correct
10 Correct 85 ms 12964 KB Output is correct
11 Correct 83 ms 12552 KB Output is correct
12 Correct 64 ms 9236 KB Output is correct
13 Correct 49 ms 8208 KB Output is correct
14 Correct 66 ms 9888 KB Output is correct
15 Correct 72 ms 9896 KB Output is correct
16 Correct 2 ms 588 KB Output is correct
17 Correct 53 ms 7848 KB Output is correct
18 Correct 49 ms 7772 KB Output is correct
19 Correct 64 ms 9232 KB Output is correct
20 Correct 101 ms 12756 KB Output is correct
21 Correct 93 ms 12548 KB Output is correct
22 Correct 89 ms 12548 KB Output is correct