답안 #1067945

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1067945 2024-08-21T05:54:09 Z Ignut 자동 인형 (IOI18_doll) C++17
6 / 100
55 ms 12484 KB
// Ignut

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

void answer(vector<int> C, vector<int> X, vector<int> Y);

void create_circuit(int M, vector<int> A) {
    int N = A.size();
    vector<int> edges[M + 1];
    edges[0].push_back(A[0]);
    for (int i = 0; i + 1 < N; i ++)
        edges[A[i]].push_back(A[i + 1]);
    edges[A.back()].push_back(0);

    vector<int> C(M + 1);
    int nextSwitch = -1;
    vector<int> X, Y;
    for (int i = 0; i <= M; i ++) {
        if (edges[i].empty()) {
            C[i] = i; continue;
        }
        if (edges[i].size() == 1) {
            C[i] = edges[i][0]; continue;
        }
        vector<int> sw;
        for (int j = 0; j < edges[i].size() - 1; j ++) {
            sw.push_back(nextSwitch --);
        }
        C[i] = sw.front();
        for (int j = 0; j < sw.size(); j ++) {
            X.push_back(edges[i][j]);
            if (j + 1 == sw.size())
                Y.push_back(edges[i][j + 1]);
            else
                Y.push_back(sw[j + 1]);
        }
        // cerr << i << " : " << sw.size() << '\n';
    }
    answer(C, X, Y);
    return;
}


/*
4 4
1 2 1 3
*/

Compilation message

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:29:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |         for (int j = 0; j < edges[i].size() - 1; j ++) {
      |                         ~~^~~~~~~~~~~~~~~~~~~~~
doll.cpp:33:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         for (int j = 0; j < sw.size(); j ++) {
      |                         ~~^~~~~~~~~~~
doll.cpp:35:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |             if (j + 1 == sw.size())
      |                 ~~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 23 ms 6748 KB Output is correct
3 Correct 14 ms 5724 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 8 ms 3928 KB Output is correct
6 Correct 31 ms 8528 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 23 ms 6748 KB Output is correct
3 Correct 14 ms 5724 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 8 ms 3928 KB Output is correct
6 Correct 31 ms 8528 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 55 ms 8212 KB Output is correct
9 Correct 36 ms 9680 KB Output is correct
10 Correct 48 ms 12484 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 432 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 23 ms 6748 KB Output is correct
3 Correct 14 ms 5724 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 8 ms 3928 KB Output is correct
6 Correct 31 ms 8528 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 55 ms 8212 KB Output is correct
9 Correct 36 ms 9680 KB Output is correct
10 Correct 48 ms 12484 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 432 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Incorrect 49 ms 10940 KB wrong motion
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB wrong motion
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB wrong motion
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB wrong motion
2 Halted 0 ms 0 KB -