Submission #788497

# Submission time Handle Problem Language Result Execution time Memory
788497 2023-07-20T09:36:42 Z Andrey Mechanical Doll (IOI18_doll) C++14
53 / 100
109 ms 21936 KB
#include "doll.h"
#include<bits/stdc++.h>
using namespace std;

vector<int> haha[200001];
vector<int> idk(500001);

void create_circuit(int m, vector<int> bruh) {
    vector<int> c(m+1);
    c[0] = bruh[0];
    int n = bruh.size();
    bruh.push_back(0);
    vector<int> x(0);
    vector<int> y(0);
    int br = 1,a,z = 0,b,p,d,e;
    for(int i = 0; i < n; i++) {
        haha[bruh[i]].push_back(bruh[i+1]);
    }
    for(int i = 0; i < 200001; i++) {
        if(haha[i].empty()) {
            continue;
        }
        if(haha[i].size() == 1) {
            c[i] = haha[i][0];
        }
        else {
            c[i] = -br;
            z = 1;
            b = 0;
            while(z < haha[i].size()) {
                z*=2;
                b*=2;
                b++;
            }
            for(int j = 0; j < b; j++) {
                x.push_back(-(br+j*2+1));
                y.push_back(-(br+j*2+2));
            }
            int p = haha[i].size()-z;
            for(int j = 0; j < z; j++) {
                d = br;
                while(d-br < b/2) {
                    if((++idk[d])%2) {
                        d = -x[d-1];
                    }
                    else {
                        d = -y[d-1];
                    }
                }
                if(p >= 0) {
                    e = haha[i][p];
                }
                else {
                    e = -br;
                }
                if((++idk[d])%2) {
                    x[d-1] = e;
                }
                else {
                    y[d-1] = e;
                }
                p++;
            }
            br+=b;
        }
    }
    answer(c,x,y);
}

Compilation message

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:30:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |             while(z < haha[i].size()) {
      |                   ~~^~~~~~~~~~~~~~~~
doll.cpp:15:16: warning: unused variable 'a' [-Wunused-variable]
   15 |     int br = 1,a,z = 0,b,p,d,e;
      |                ^
doll.cpp:15:26: warning: unused variable 'p' [-Wunused-variable]
   15 |     int br = 1,a,z = 0,b,p,d,e;
      |                          ^
# Verdict Execution time Memory Grader output
1 Correct 3 ms 6868 KB Output is correct
2 Correct 23 ms 11048 KB Output is correct
3 Correct 20 ms 10768 KB Output is correct
4 Correct 3 ms 6972 KB Output is correct
5 Correct 10 ms 8120 KB Output is correct
6 Correct 29 ms 12748 KB Output is correct
7 Correct 3 ms 6868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 6868 KB Output is correct
2 Correct 23 ms 11048 KB Output is correct
3 Correct 20 ms 10768 KB Output is correct
4 Correct 3 ms 6972 KB Output is correct
5 Correct 10 ms 8120 KB Output is correct
6 Correct 29 ms 12748 KB Output is correct
7 Correct 3 ms 6868 KB Output is correct
8 Correct 48 ms 13704 KB Output is correct
9 Correct 36 ms 14020 KB Output is correct
10 Correct 58 ms 17700 KB Output is correct
11 Correct 4 ms 6868 KB Output is correct
12 Correct 4 ms 6868 KB Output is correct
13 Correct 4 ms 6968 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 6868 KB Output is correct
2 Correct 23 ms 11048 KB Output is correct
3 Correct 20 ms 10768 KB Output is correct
4 Correct 3 ms 6972 KB Output is correct
5 Correct 10 ms 8120 KB Output is correct
6 Correct 29 ms 12748 KB Output is correct
7 Correct 3 ms 6868 KB Output is correct
8 Correct 48 ms 13704 KB Output is correct
9 Correct 36 ms 14020 KB Output is correct
10 Correct 58 ms 17700 KB Output is correct
11 Correct 4 ms 6868 KB Output is correct
12 Correct 4 ms 6868 KB Output is correct
13 Correct 4 ms 6968 KB Output is correct
14 Correct 69 ms 18084 KB Output is correct
15 Correct 40 ms 13600 KB Output is correct
16 Correct 59 ms 15744 KB Output is correct
17 Correct 4 ms 6968 KB Output is correct
18 Correct 5 ms 6868 KB Output is correct
19 Correct 5 ms 6868 KB Output is correct
20 Correct 60 ms 17028 KB Output is correct
21 Correct 5 ms 6868 KB Output is correct
22 Correct 4 ms 6868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 6868 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 3 ms 6868 KB Output is partially correct
2 Correct 46 ms 13900 KB Output is correct
3 Partially correct 88 ms 15732 KB Output is partially correct
4 Partially correct 87 ms 17276 KB Output is partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 3 ms 6868 KB Output is partially correct
2 Correct 46 ms 13900 KB Output is correct
3 Partially correct 88 ms 15732 KB Output is partially correct
4 Partially correct 87 ms 17276 KB Output is partially correct
5 Partially correct 83 ms 19268 KB Output is partially correct
6 Partially correct 82 ms 20260 KB Output is partially correct
7 Partially correct 81 ms 19988 KB Output is partially correct
8 Partially correct 82 ms 20604 KB Output is partially correct
9 Partially correct 94 ms 16968 KB Output is partially correct
10 Partially correct 109 ms 21936 KB Output is partially correct
11 Partially correct 96 ms 21216 KB Output is partially correct
12 Partially correct 62 ms 16840 KB Output is partially correct
13 Partially correct 61 ms 15476 KB Output is partially correct
14 Partially correct 53 ms 15312 KB Output is partially correct
15 Partially correct 49 ms 14972 KB Output is partially correct
16 Partially correct 5 ms 7272 KB Output is partially correct
17 Partially correct 46 ms 14704 KB Output is partially correct
18 Partially correct 57 ms 14708 KB Output is partially correct
19 Partially correct 49 ms 15788 KB Output is partially correct
20 Partially correct 64 ms 17888 KB Output is partially correct
21 Partially correct 83 ms 19632 KB Output is partially correct
22 Partially correct 60 ms 17448 KB Output is partially correct