Submission #827787

# Submission time Handle Problem Language Result Execution time Memory
827787 2023-08-16T18:37:49 Z AlesL0 Mechanical Doll (IOI18_doll) C++17
6 / 100
1000 ms 15696 KB
#include <bits/stdc++.h>
#include "doll.h"

using namespace std;

int current = 1;
vector <int> X, Y, C;

bool check_same(vector <int> v){
    for (int i = 0; i < v.size()-1; i++)if (v[i] != v[i+1])return 0;
    return 1;
}

int solve(vector <int> v){
    if (check_same(v))return v[0];
    vector <int> v1, v2;
    int c = current++;
    if (v.size() & 1){
        v.push_back(-c);
        swap(v[v.size()-1], v[v.size()-2]);
    }
    for (int i = 0; i < v.size(); i+=2)v1.push_back(v[i]);
    for (int i = 1; i < v.size(); i+=2)v2.push_back(v[i]);
    int a = solve(v1), b = solve(v2);
    X[c-1] = a;
    Y[c-1] = b;
    return -c;
}

void create_circuit(int M, std::vector<int> A) {
    vector <vector <int>> dest(M+1);
    const int INF = -100000000;
    X.resize(400000, INF);
    Y.resize(400000, INF);
    A.push_back(0);
    dest[0].push_back(A[0]);
    for (int i = 0; i < A.size()-1; i++)dest[A[i]].push_back(A[i+1]);
    C.resize(M+1);
    for (int i = 0; i <= M; i++){
        if (dest[i].empty()){
            C[i] = i;
            continue;
        }
        C[i] = solve(dest[i]);
    }
    for (auto x : C)cerr << x << " ";
    cerr << "\n";
    while (!X.empty() && X.back() == INF)X.pop_back();
    while (!Y.empty() && Y.back() == INF)Y.pop_back();
    for (int i = 0; i < X.size(); i++)cerr << X[i] << " " << Y[i] << "\n";
    answer(C, X, Y);
}

Compilation message

doll.cpp: In function 'bool check_same(std::vector<int>)':
doll.cpp:10:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for (int i = 0; i < v.size()-1; i++)if (v[i] != v[i+1])return 0;
      |                     ~~^~~~~~~~~~~~
doll.cpp: In function 'int solve(std::vector<int>)':
doll.cpp:22:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     for (int i = 0; i < v.size(); i+=2)v1.push_back(v[i]);
      |                     ~~^~~~~~~~~~
doll.cpp:23:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     for (int i = 1; i < v.size(); i+=2)v2.push_back(v[i]);
      |                     ~~^~~~~~~~~~
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:37:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     for (int i = 0; i < A.size()-1; i++)dest[A[i]].push_back(A[i+1]);
      |                     ~~^~~~~~~~~~~~
doll.cpp:50:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |     for (int i = 0; i < X.size(); i++)cerr << X[i] << " " << Y[i] << "\n";
      |                     ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 3412 KB Output is correct
2 Correct 229 ms 10068 KB Output is correct
3 Correct 155 ms 8696 KB Output is correct
4 Correct 2 ms 3412 KB Output is correct
5 Correct 245 ms 7484 KB Output is correct
6 Correct 242 ms 11372 KB Output is correct
7 Correct 2 ms 3412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 3412 KB Output is correct
2 Correct 229 ms 10068 KB Output is correct
3 Correct 155 ms 8696 KB Output is correct
4 Correct 2 ms 3412 KB Output is correct
5 Correct 245 ms 7484 KB Output is correct
6 Correct 242 ms 11372 KB Output is correct
7 Correct 2 ms 3412 KB Output is correct
8 Correct 475 ms 10940 KB Output is correct
9 Correct 443 ms 12452 KB Output is correct
10 Correct 711 ms 15020 KB Output is correct
11 Correct 2 ms 3412 KB Output is correct
12 Correct 2 ms 3412 KB Output is correct
13 Correct 2 ms 3412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 3412 KB Output is correct
2 Correct 229 ms 10068 KB Output is correct
3 Correct 155 ms 8696 KB Output is correct
4 Correct 2 ms 3412 KB Output is correct
5 Correct 245 ms 7484 KB Output is correct
6 Correct 242 ms 11372 KB Output is correct
7 Correct 2 ms 3412 KB Output is correct
8 Correct 475 ms 10940 KB Output is correct
9 Correct 443 ms 12452 KB Output is correct
10 Correct 711 ms 15020 KB Output is correct
11 Correct 2 ms 3412 KB Output is correct
12 Correct 2 ms 3412 KB Output is correct
13 Correct 2 ms 3412 KB Output is correct
14 Execution timed out 1077 ms 15696 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 3412 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 2 ms 3412 KB Output is partially correct
2 Correct 16 ms 6992 KB Output is correct
3 Execution timed out 1083 ms 9756 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 2 ms 3412 KB Output is partially correct
2 Correct 16 ms 6992 KB Output is correct
3 Execution timed out 1083 ms 9756 KB Time limit exceeded
4 Halted 0 ms 0 KB -