Submission #1069258

# Submission time Handle Problem Language Result Execution time Memory
1069258 2024-08-21T18:19:31 Z andrei_iorgulescu Mechanical Doll (IOI18_doll) C++14
24 / 100
55 ms 14344 KB
#include <bits/stdc++.h>
#include "doll.h"
#warning That's not FB, that's my FB

using namespace std;

int n,m;
vector<int> a;
vector<vector<int>> pos;
vector<int> unde;
int cur = 1;

vector<int> c, x, y;

int ngl, kgl, pgl;

void build(int nume, int l, int r)
{
    int mij = (l + r) / 2;
    if (mij <= pgl)
        x[-nume - 1] = c[ngl];
    else
    {
        if (l != mij)
        {
            x[-nume - 1] = -cur;
            cur++;
            x.push_back(0);
            y.push_back(0);
            build(x[-nume - 1], l, mij);
        }
        else
        {
            int pz = pos[ngl][unde[ngl]] + 1;
            unde[ngl]++;
            x[-nume - 1] = a[pz];
        }
    }
    if (mij + 1 != r)
    {
        y[-nume - 1] = -cur;
        cur++;
        x.push_back(0);
        y.push_back(0);
        build(y[-nume - 1], mij + 1, r);
    }
    else
    {
        int pz = pos[ngl][unde[ngl]] + 1;
        unde[ngl]++;
        y[-nume - 1] = a[pz];
    }
}

void build_sgt(int nod)
{
    c[nod] = -cur;
    cur++;
    x.push_back(0);
    y.push_back(0);
    ngl = nod;
    kgl = __lg(pos[nod].size());
    if ((1 << kgl) < pos[nod].size())
        kgl++;
    pgl = (1 << kgl) - (int)pos[nod].size();
    build(c[nod], 1, (1 << kgl));
}

void create_circuit(int M, vector<int> A)
{
    n = A.size();
    a = A;
    m = M;
    pos.resize(m + 1);
    unde.resize(m + 1);
    for (int i = 0; i < a.size(); i++)
        pos[a[i]].push_back(i);
    a.push_back(0);
    c.resize(m + 1);
    c[0] = a[0];
    for (int i = 1; i <= m; i++)
    {
        if (pos[i].empty())
            c[i] = 0;
        else if (pos[i].size() == 1)
            c[i] = a[pos[i][0] + 1];
        else
            build_sgt(i);
    }
    /*for (auto it : c)
        cout << it << ' ';
    cout << endl;
    for (auto it : x)
        cout << it << ' ';
    cout << endl;
    for (auto it : y)
        cout << it << ' ';
    cout << endl;*/
    answer(c, x, y);
}

Compilation message

doll.cpp:3:2: warning: #warning That's not FB, that's my FB [-Wcpp]
    3 | #warning That's not FB, that's my FB
      |  ^~~~~~~
doll.cpp: In function 'void build_sgt(int)':
doll.cpp:63:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |     if ((1 << kgl) < pos[nod].size())
      |         ~~~~~~~~~~~^~~~~~~~~~~~~~~~~
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:76:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   76 |     for (int i = 0; i < a.size(); i++)
      |                     ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 16 ms 7064 KB Output is correct
3 Correct 14 ms 5720 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 7 ms 4188 KB Output is correct
6 Correct 20 ms 8780 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 16 ms 7064 KB Output is correct
3 Correct 14 ms 5720 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 7 ms 4188 KB Output is correct
6 Correct 20 ms 8780 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 30 ms 8776 KB Output is correct
9 Correct 30 ms 10028 KB Output is correct
10 Correct 48 ms 13628 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 16 ms 7064 KB Output is correct
3 Correct 14 ms 5720 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 7 ms 4188 KB Output is correct
6 Correct 20 ms 8780 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 30 ms 8776 KB Output is correct
9 Correct 30 ms 10028 KB Output is correct
10 Correct 48 ms 13628 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Incorrect 54 ms 14344 KB wrong motion
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB wrong motion
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 24 ms 6436 KB Output is correct
3 Correct 24 ms 6128 KB Output is correct
4 Correct 38 ms 9348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 24 ms 6436 KB Output is correct
3 Correct 24 ms 6128 KB Output is correct
4 Correct 38 ms 9348 KB Output is correct
5 Incorrect 55 ms 13964 KB wrong motion
6 Halted 0 ms 0 KB -