답안 #116373

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
116373 2019-06-12T10:57:32 Z zubec 자동 인형 (IOI18_doll) C++14
10 / 100
2 ms 204 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 = 2;
    while(sz < n)
        sz += sz;
    for (int i = 2; i <= n; i++){
        add(1, 1, sz, A[i-1]);
    }
    for (int i = n+1; 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;
      |         ^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB state 'Y'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB state 'Y'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB state 'Y'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 2 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 2 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 204 KB state 'Y'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 204 KB state 'Y'
2 Halted 0 ms 0 KB -