Submission #116375

# Submission time Handle Problem Language Result Execution time Memory
116375 2019-06-12T10:59:51 Z zubec Mechanical Doll (IOI18_doll) C++14
47 / 100
159 ms 10480 KB
#include "doll.h"
#include <bits/stdc++.h>
using namespace std;

const int N = 200100;

int dir[N*4], n, sz;

pair<int, int> pr[N];

void add(int v, int l, int r, int x){
    if (l == r){
        //cout << "kek " << v << ' ' << v/2-sz/2+1 << ' ' << x << endl;
        if (v % 2 == 0)
            pr[v/2-sz/2+1].first = x; else
            pr[v/2-sz/2+1].second = x;
        return;
    }
    int mid = (l+r)>>1;
    if (dir[v] == 0)
        add(v+v, l, mid, x); else
        add(v+v+1, mid+1, r, x);
    dir[v] ^= 1;
}

void create_circuit(int M, std::vector<int> A) {
    n = A.size();
    vector <int> C, X, Y;
    if (n == 1){
        C.push_back(A[0]);
        for (int i = 1; i <= M; i++)
            C.push_back(0);
        answer(C, X, Y);
        return;
    }
    sz = 1;
    while(sz < n)
        sz += sz;
    for (int i = 2; i <= n; i++){
        add(1, 1, sz, A[i-1]);
    }
    for (int i = n; i < sz; i++){
        add(1, 1, sz, -1);
    }
    add(1, 1, sz, 0);
    C.push_back(A[0]);
    for (int i = 1; i <= M; i++)
        C.push_back(-1);
    for (int i = 1; i <= sz/2-1; i++){
        X.push_back(-(i+i));
        Y.push_back(-(i+i+1));
    }
    int kol = 0;
    for (int i = 1; i <= sz/2; i++){
        X.push_back(pr[i].first);
        Y.push_back(pr[i].second);
    }

    answer(C, X, Y);
}

/**

4 4
1 2 1 3

*/

Compilation message

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:53:9: warning: unused variable 'kol' [-Wunused-variable]
   53 |     int kol = 0;
      |         ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 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 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 204 KB Output is partially correct
2 Correct 67 ms 5560 KB Output is correct
3 Partially correct 113 ms 9756 KB Output is partially correct
4 Partially correct 159 ms 10416 KB Output is partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 204 KB Output is partially correct
2 Correct 67 ms 5560 KB Output is correct
3 Partially correct 113 ms 9756 KB Output is partially correct
4 Partially correct 159 ms 10416 KB Output is partially correct
5 Partially correct 138 ms 10480 KB Output is partially correct
6 Partially correct 125 ms 10288 KB Output is partially correct
7 Partially correct 135 ms 10416 KB Output is partially correct
8 Partially correct 151 ms 10240 KB Output is partially correct
9 Partially correct 114 ms 9776 KB Output is partially correct
10 Partially correct 132 ms 10284 KB Output is partially correct
11 Partially correct 129 ms 10196 KB Output is partially correct
12 Partially correct 116 ms 9684 KB Output is partially correct
13 Correct 69 ms 5648 KB Output is correct
14 Partially correct 130 ms 9764 KB Output is partially correct
15 Partially correct 131 ms 9848 KB Output is partially correct
16 Partially correct 4 ms 588 KB Output is partially correct
17 Correct 64 ms 5592 KB Output is correct
18 Correct 67 ms 5560 KB Output is correct
19 Partially correct 111 ms 9696 KB Output is partially correct
20 Partially correct 132 ms 10144 KB Output is partially correct
21 Partially correct 125 ms 10204 KB Output is partially correct
22 Partially correct 135 ms 10208 KB Output is partially correct