Submission #1111031

# Submission time Handle Problem Language Result Execution time Memory
1111031 2024-11-11T10:38:28 Z HasanV11010238 Mechanical Doll (IOI18_doll) C++17
37 / 100
83 ms 17276 KB
#include "doll.h"
#include <bits/stdc++.h>
using namespace std;
#define MAX 3000000
vector<vector<int>> ve;
vector<int> x, y, de;
int nxt = 0, n;
int create(){
    nxt++;
    x.push_back(0), y.push_back(0);
    return nxt;
}
void mktr(int no, int ri, int md, int d){
    if (d == md - 1){
        x[no - 1] = -ri;
        y[no - 1] = -ri;
        return;
    }
    x[no - 1] = -create();
    mktr(-x[no - 1], ri, md, d + 1);
    y[no - 1] = -create();
    mktr(-y[no - 1], ri, md, d + 1);
}
void connect(int no, int in, int md, int d, int wh){
    int val = (1<<d) & in;
    if (d == md - 1){
        if (val == 0){
            x[no - 1] = wh;
        }
        else{
            y[no - 1] = wh;
        }
    }
    else{
        if (val == 0){
            connect(-x[no - 1], in, md, d + 1, wh);
        }
        else{
            connect(-y[no - 1], in, md, d + 1, wh);
        }
    }
}
void create_circuit(int M, vector<int> A){
    n = A.size();
    vector<int> tr(M + 1, 0);
    ve.assign(M + 1, vector<int>()), de.assign(M + 1, 0);
    for (int i = 0; i < n - 1; i++){
        ve[A[i]].push_back(A[i + 1]);
    }
    tr[0] = A[0];
    for (int i = 1; i <= M; i++){
        int d = ceil(log2(ve[i].size() + 2));
        de[i] = d;
        tr[i] = -create();
        mktr(-tr[i], -tr[i], d, 0);
        for (int j = 0; j < ve[i].size(); j++){
            connect(-tr[i], j, d, 0, ve[i][j]);
        }
    }
    connect(-tr[A[n - 1]], ve[A[n - 1]].size(), de[A[n - 1]], 0, tr[1]);
    for (int i = 1; i < M; i++){
        connect(-tr[i], (1<<de[i]) - 1, de[i], 0, tr[i + 1]);
    }
    connect(-tr[M], (1<<de[M]) - 1, de[M], 0, 0);
    answer(tr, x, y);
}

Compilation message

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:56:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |         for (int j = 0; j < ve[i].size(); j++){
      |                         ~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 336 KB Output is partially correct
2 Partially correct 66 ms 9876 KB Output is partially correct
3 Partially correct 60 ms 9800 KB Output is partially correct
4 Partially correct 68 ms 10328 KB Output is partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 336 KB Output is partially correct
2 Partially correct 66 ms 9876 KB Output is partially correct
3 Partially correct 60 ms 9800 KB Output is partially correct
4 Partially correct 68 ms 10328 KB Output is partially correct
5 Partially correct 82 ms 16716 KB Output is partially correct
6 Partially correct 83 ms 17160 KB Output is partially correct
7 Partially correct 68 ms 17032 KB Output is partially correct
8 Partially correct 70 ms 17268 KB Output is partially correct
9 Partially correct 51 ms 10192 KB Output is partially correct
10 Partially correct 75 ms 17264 KB Output is partially correct
11 Partially correct 68 ms 17276 KB Output is partially correct
12 Partially correct 45 ms 10772 KB Output is partially correct
13 Partially correct 48 ms 10356 KB Output is partially correct
14 Partially correct 47 ms 10008 KB Output is partially correct
15 Partially correct 44 ms 9744 KB Output is partially correct
16 Partially correct 2 ms 760 KB Output is partially correct
17 Partially correct 45 ms 8916 KB Output is partially correct
18 Partially correct 47 ms 8808 KB Output is partially correct
19 Partially correct 40 ms 9056 KB Output is partially correct
20 Partially correct 56 ms 14364 KB Output is partially correct
21 Partially correct 68 ms 15484 KB Output is partially correct
22 Partially correct 65 ms 10972 KB Output is partially correct