Submission #836137

# Submission time Handle Problem Language Result Execution time Memory
836137 2023-08-24T07:52:26 Z mousebeaver Mechanical Doll (IOI18_doll) C++14
53 / 100
122 ms 13608 KB
#include "doll.h"
#include <bits/stdc++.h>
using namespace std;

void dfs(vector<int> adjlist, vector<int>& x, vector<int>& y)
{
    //adjlist.size() > 1, insert new switch
    if(adjlist.size()%2 == 1)
    {
        adjlist.insert(adjlist.begin()+1, -(x.size()+1));
    }

    if(adjlist.size()%2 == 0)
    {
        x.push_back(0);
        y.push_back(0);
        int index = x.size()-1;    
        if(adjlist.size() == 2)
        {
            x.back() = adjlist[0];
            y.back() = adjlist[1];
            return;
        }
        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]);
            }
        }
        
        x[index] = -(x.size()+1);
        dfs(even, x, y);

        y[index] = -(x.size()+1);
        dfs(odd, x, y);
        return;
    }

    /*//Uneven size of adjlist?
    int index = x.size();
    x.push_back(0);
    y.push_back(0);
    x.back() = -(x.size()+1);
    y.back() = -(x.size()+2);
    x.push_back(adjlist[0]);
    y.push_back(adjlist[1]);
    x.push_back(-(index+1));
    y.push_back(adjlist[2]);*/
}

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);
    }

    answer(c, x, y);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 19 ms 6612 KB Output is correct
3 Correct 16 ms 5324 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 8 ms 3796 KB Output is correct
6 Correct 23 ms 7892 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 19 ms 6612 KB Output is correct
3 Correct 16 ms 5324 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 8 ms 3796 KB Output is correct
6 Correct 23 ms 7892 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 33 ms 7496 KB Output is correct
9 Correct 35 ms 8848 KB Output is correct
10 Correct 58 ms 11296 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 212 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 19 ms 6612 KB Output is correct
3 Correct 16 ms 5324 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 8 ms 3796 KB Output is correct
6 Correct 23 ms 7892 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 33 ms 7496 KB Output is correct
9 Correct 35 ms 8848 KB Output is correct
10 Correct 58 ms 11296 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 71 ms 11184 KB Output is correct
15 Correct 37 ms 6084 KB Output is correct
16 Correct 58 ms 8892 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 76 ms 10920 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 384 KB Output is partially correct
2 Correct 44 ms 5988 KB Output is correct
3 Partially correct 78 ms 11128 KB Output is partially correct
4 Partially correct 88 ms 11056 KB Output is partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 384 KB Output is partially correct
2 Correct 44 ms 5988 KB Output is correct
3 Partially correct 78 ms 11128 KB Output is partially correct
4 Partially correct 88 ms 11056 KB Output is partially correct
5 Partially correct 95 ms 12388 KB Output is partially correct
6 Partially correct 103 ms 12852 KB Output is partially correct
7 Partially correct 102 ms 12720 KB Output is partially correct
8 Partially correct 113 ms 13232 KB Output is partially correct
9 Partially correct 78 ms 9240 KB Output is partially correct
10 Partially correct 122 ms 13092 KB Output is partially correct
11 Partially correct 117 ms 13608 KB Output is partially correct
12 Partially correct 75 ms 9180 KB Output is partially correct
13 Partially correct 67 ms 8836 KB Output is partially correct
14 Partially correct 67 ms 8632 KB Output is partially correct
15 Partially correct 60 ms 8448 KB Output is partially correct
16 Partially correct 2 ms 596 KB Output is partially correct
17 Partially correct 60 ms 7552 KB Output is partially correct
18 Partially correct 60 ms 7608 KB Output is partially correct
19 Partially correct 84 ms 7956 KB Output is partially correct
20 Partially correct 82 ms 10108 KB Output is partially correct
21 Partially correct 103 ms 11924 KB Output is partially correct
22 Partially correct 83 ms 9596 KB Output is partially correct