Submission #940790

# Submission time Handle Problem Language Result Execution time Memory
940790 2024-03-07T15:57:27 Z snpmrnhlol Mechanical Doll (IOI18_doll) C++17
37 / 100
99 ms 12240 KB
#include "doll.h"
#include <bits/stdc++.h>
using namespace std;
void create_circuit(int m, vector<int> a) {
    int n = a.size();
    int len = 0;
    int cnt = -2;
    while((1<<len) < n + 1)len++;
    vector <int> c(m + 1);
    vector <int> x((1<<len) - 1);
    vector <int> y((1<<len) - 1);
    vector <array<int,3>> ord;
    for(int i = 0;i < m + 1;i++){
        c[i] = -1;
    }
    auto dfs = [&](auto self,int node,int d) -> void {
        if(d == len - 1){
            x[-node - 1] = -1;
            y[-node - 1] = -1;
        }else{
            x[-node - 1] = cnt--;
            self(self,cnt + 1,d + 1);
            y[-node - 1] = cnt--;
            self(self,cnt + 1,d + 1);
        }
    };
    int cnt2 = 0,last = 0;
    auto dfs2 = [&](auto self,int node,int d) -> void {
        if(d == len - 1){
            int nr = 0;
            for(int j = 0;j < len;j++){
                if(cnt2>>j&1){
                    nr|=(1<<(len - j - 1));
                }
            }
            if(cnt2 < n)ord.push_back({nr,node,0});
            cnt2++;
            if(cnt2 < n)ord.push_back({nr + (1<<len),node,1});
            cnt2++;
            last = node;
        }else{
            self(self,-x[node] - 1,d + 1);
            self(self,-y[node] - 1,d + 1);
        }
    };
    dfs(dfs,-1,0);
    dfs2(dfs2,0,0);
    int cnt3 = 0;
    sort(ord.begin(),ord.end());
    for(auto i:ord){
        //cout<<i[0]<<' '<<i[1]<<' '<<i[2]<<'\n';
        if(i[2] == 0){
            x[i[1]] = a[cnt3];
        }else{
            y[i[1]] = a[cnt3];
        }
        cnt3++;
    }
    y[last] = 0;
    /*for(int i = 0;i < (1<<len) - 1;i++){
        cout<<x[i]<<' '<<y[i]<<'\n';
    }*/
    return answer(c,x,y);
}
/**
5 4
1 2 3 1
**/
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 348 KB Output is partially correct
2 Partially correct 69 ms 10188 KB Output is partially correct
3 Partially correct 68 ms 9844 KB Output is partially correct
4 Partially correct 81 ms 11972 KB Output is partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 348 KB Output is partially correct
2 Partially correct 69 ms 10188 KB Output is partially correct
3 Partially correct 68 ms 9844 KB Output is partially correct
4 Partially correct 81 ms 11972 KB Output is partially correct
5 Partially correct 85 ms 12228 KB Output is partially correct
6 Partially correct 86 ms 12184 KB Output is partially correct
7 Partially correct 87 ms 12240 KB Output is partially correct
8 Partially correct 84 ms 11968 KB Output is partially correct
9 Partially correct 67 ms 9920 KB Output is partially correct
10 Partially correct 87 ms 12224 KB Output is partially correct
11 Partially correct 86 ms 11940 KB Output is partially correct
12 Partially correct 69 ms 9920 KB Output is partially correct
13 Partially correct 71 ms 10272 KB Output is partially correct
14 Partially correct 77 ms 11316 KB Output is partially correct
15 Partially correct 78 ms 10180 KB Output is partially correct
16 Partially correct 3 ms 604 KB Output is partially correct
17 Correct 46 ms 7008 KB Output is correct
18 Partially correct 69 ms 10188 KB Output is partially correct
19 Partially correct 99 ms 9888 KB Output is partially correct
20 Partially correct 83 ms 12232 KB Output is partially correct
21 Partially correct 84 ms 12228 KB Output is partially correct
22 Partially correct 84 ms 11964 KB Output is partially correct