답안 #836080

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
836080 2023-08-24T07:04:04 Z mousebeaver 자동 인형 (IOI18_doll) C++14
6 / 100
59 ms 11332 KB
#include "doll.h"
#include <bits/stdc++.h>
using namespace std;

void dfs(vector<int> adjlist, vector<int>& x, vector<int>& y, vector<int>& c)
{
    //adjlist.size() > 1, insert new switch
    x.push_back(0);
    y.push_back(0);
    int index = x.size()-1;    
    vector<int> even(0);
    vector<int> odd(0);
    for(int i = 0; i < (int) adjlist.size(); i++)
    {
        if(i%2 == 0)
        {
            even.push_back(adjlist[i]);
        }
        else
        {
            odd.push_back(adjlist[i]);
        }
    }

    if(even.size() == 1)
    {
        x[index] = even[0];
    }
    else
    {
        x[index] = -(x.size()+1);
        dfs(even, x, y, c);
    }

    if(odd.size() == 1)
    {
        y[index] = odd[0];
    }
    else
    {
        y[index] = (-y.size()+1);
        dfs(odd, x, y, c);
    }
}

void create_circuit(int m, std::vector<int> a) 
{
    int n = a.size();
    vector<vector<int>> adjlist(m+1, vector<int> (0));
    adjlist[0] = {a[0]};
    for(int i = 0; i < n-1; i++)
    {
        adjlist[a[i]].push_back(a[i+1]);
    }
    adjlist[a[n-1]].push_back(0);

    vector<int> c(m+1, 0);
    vector<int> x(0);
    vector<int> y(0);

    for(int i = 0; i <= m; i++)
    {
        if(adjlist[i].empty())
        {
            continue;
        }
        if(adjlist[i].size() == 1)
        {
            c[i] = adjlist[i][0];
            continue;
        }
        c[i] = -(x.size()+1);
        dfs(adjlist[i], x, y, c);
    }

    answer(c, x, y);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 20 ms 6612 KB Output is correct
3 Correct 15 ms 5460 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 8 ms 3796 KB Output is correct
6 Correct 26 ms 7816 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 20 ms 6612 KB Output is correct
3 Correct 15 ms 5460 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 8 ms 3796 KB Output is correct
6 Correct 26 ms 7816 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 37 ms 7368 KB Output is correct
9 Correct 39 ms 8912 KB Output is correct
10 Correct 55 ms 11332 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 20 ms 6612 KB Output is correct
3 Correct 15 ms 5460 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 8 ms 3796 KB Output is correct
6 Correct 26 ms 7816 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 37 ms 7368 KB Output is correct
9 Correct 39 ms 8912 KB Output is correct
10 Correct 55 ms 11332 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Incorrect 59 ms 9704 KB state 'Y'
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 304 KB wrong motion
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 304 KB wrong motion
2 Halted 0 ms 0 KB -