Submission #885731

# Submission time Handle Problem Language Result Execution time Memory
885731 2023-12-10T14:47:44 Z JakobZorz Mechanical Doll (IOI18_doll) C++17
37 / 100
117 ms 13344 KB
#include"doll.h"
#include<iostream>
#include<algorithm>
using namespace std;

vector<int>sx,sy;
vector<int>arr;

int new_switch(){
    sx.push_back(0);
    sy.push_back(0);
    return(int)sx.size()-1;
}

pair<vector<int>,vector<int>>split(vector<int>vec){
    pair<vector<int>,vector<int>>res;
    for(int i=0;i<vec.size();i++){
        if(i%2==0)
            res.first.push_back(vec[i]);
        else
            res.second.push_back(vec[i]);
    }
    return res;
}

int build(vector<int>exits){
    if(exits.size()==1)
        return exits[0];
    
    int root=new_switch();
    
    pair<vector<int>,vector<int>>res=split(exits);
    sx[root]=build(res.first);
    sy[root]=build(res.second);
    
    return -root-1;
}

void create_circuit(int m,vector<int>_arr){
    arr=_arr;
    int n=(int)arr.size();
    
    vector<int>ans(m+1);
    
    vector<int>exits=arr;
    exits.push_back(0);
    reverse(exits.begin(),exits.end());
    int pow2=1;
    while(pow2<(int)exits.size())
        pow2*=2;
    while(exits.size()<pow2)
        exits.push_back(-1);
    reverse(exits.begin(),exits.end());
    
    int root=build(exits);
    for(int&i:ans)
        i=root;
    
    answer(ans,sx,sy);
}

Compilation message

doll.cpp: In function 'std::pair<std::vector<int>, std::vector<int> > split(std::vector<int>)':
doll.cpp:17:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for(int i=0;i<vec.size();i++){
      |                 ~^~~~~~~~~~~
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:51:23: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   51 |     while(exits.size()<pow2)
      |           ~~~~~~~~~~~~^~~~~
doll.cpp:41:9: warning: unused variable 'n' [-Wunused-variable]
   41 |     int n=(int)arr.size();
      |         ^
# 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 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 348 KB Output is partially correct
2 Partially correct 90 ms 11828 KB Output is partially correct
3 Partially correct 89 ms 11992 KB Output is partially correct
4 Partially correct 93 ms 12316 KB Output is partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 348 KB Output is partially correct
2 Partially correct 90 ms 11828 KB Output is partially correct
3 Partially correct 89 ms 11992 KB Output is partially correct
4 Partially correct 93 ms 12316 KB Output is partially correct
5 Partially correct 106 ms 13140 KB Output is partially correct
6 Partially correct 96 ms 13308 KB Output is partially correct
7 Partially correct 97 ms 13344 KB Output is partially correct
8 Partially correct 95 ms 13144 KB Output is partially correct
9 Partially correct 94 ms 11832 KB Output is partially correct
10 Partially correct 95 ms 13084 KB Output is partially correct
11 Partially correct 95 ms 12744 KB Output is partially correct
12 Partially correct 89 ms 12044 KB Output is partially correct
13 Partially correct 117 ms 12432 KB Output is partially correct
14 Partially correct 98 ms 12572 KB Output is partially correct
15 Partially correct 92 ms 12604 KB Output is partially correct
16 Partially correct 3 ms 860 KB Output is partially correct
17 Correct 49 ms 7120 KB Output is correct
18 Partially correct 97 ms 12384 KB Output is partially correct
19 Partially correct 91 ms 12092 KB Output is partially correct
20 Partially correct 94 ms 12940 KB Output is partially correct
21 Partially correct 94 ms 12712 KB Output is partially correct
22 Partially correct 96 ms 12856 KB Output is partially correct