답안 #827777

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
827777 2023-08-16T18:22:50 Z AlesL0 자동 인형 (IOI18_doll) C++17
6 / 100
1000 ms 16500 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.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: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:34:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     for (int i = 0; i < A.size()-1; i++)dest[A[i]].push_back(A[i+1]);
      |                     ~~^~~~~~~~~~~~
doll.cpp:45:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |     for (int i = 0; i < X.size(); i++)cerr << X[i] << " " << Y[i] << "\n";
      |                     ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 224 ms 7408 KB Output is correct
3 Correct 152 ms 5928 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 209 ms 4344 KB Output is correct
6 Correct 230 ms 8992 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 224 ms 7408 KB Output is correct
3 Correct 152 ms 5928 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 209 ms 4344 KB Output is correct
6 Correct 230 ms 8992 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 439 ms 9368 KB Output is correct
9 Correct 425 ms 10592 KB Output is correct
10 Correct 686 ms 14684 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 300 KB Output is correct
13 Correct 1 ms 304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 224 ms 7408 KB Output is correct
3 Correct 152 ms 5928 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 209 ms 4344 KB Output is correct
6 Correct 230 ms 8992 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 439 ms 9368 KB Output is correct
9 Correct 425 ms 10592 KB Output is correct
10 Correct 686 ms 14684 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 300 KB Output is correct
13 Correct 1 ms 304 KB Output is correct
14 Execution timed out 1037 ms 16500 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB wrong motion
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB wrong motion
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB wrong motion
2 Halted 0 ms 0 KB -