Submission #827750

# Submission time Handle Problem Language Result Execution time Memory
827750 2023-08-16T17:15:58 Z AlesL0 Mechanical Doll (IOI18_doll) C++17
6 / 100
739 ms 14608 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;
    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 c = current++;
    int a = solve(v1), b = solve(v2);
    X.push_back(a);
    Y.push_back(b);
    return -c;
}

void create_circuit(int M, std::vector<int> A) {
    vector <vector <int>> dest(M+1);
    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";
    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:17:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for (int i = 0; i < v.size(); i+=2)v1.push_back(v[i]);
      |                     ~~^~~~~~~~~~
doll.cpp:18:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |     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:30:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     for (int i = 0; i < A.size()-1; i++)dest[A[i]].push_back(A[i+1]);
      |                     ~~^~~~~~~~~~~~
doll.cpp:41:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |     for (int i = 0; i < X.size(); i++)cerr << X[i] << " " << Y[i] << "\n";
      |                     ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 222 ms 7380 KB Output is correct
3 Correct 153 ms 5892 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 212 ms 4392 KB Output is correct
6 Correct 230 ms 8972 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 222 ms 7380 KB Output is correct
3 Correct 153 ms 5892 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 212 ms 4392 KB Output is correct
6 Correct 230 ms 8972 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 443 ms 9440 KB Output is correct
9 Correct 418 ms 10588 KB Output is correct
10 Correct 690 ms 14608 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 296 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 222 ms 7380 KB Output is correct
3 Correct 153 ms 5892 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 212 ms 4392 KB Output is correct
6 Correct 230 ms 8972 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 443 ms 9440 KB Output is correct
9 Correct 418 ms 10588 KB Output is correct
10 Correct 690 ms 14608 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 296 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Incorrect 739 ms 12936 KB wrong motion
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB wrong motion
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 300 KB wrong motion
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 300 KB wrong motion
2 Halted 0 ms 0 KB -