Submission #571127

#TimeUsernameProblemLanguageResultExecution timeMemory
571127elazarkorenMechanical Doll (IOI18_doll)C++17
16 / 100
92 ms13060 KiB
#include "doll.h"
#include <bits/stdc++.h>
#define x first
#define y second
#define all(v) v.begin(), v.end()
#define chkmin(a, b) a = min(a, b)
#define chkmax(a, b) a = max(a, b)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vii;

const int MAX_M = 1e5 + 5;

vi graph[MAX_M];

void create_circuit(int m, std::vector<int> a) {
    int n = a.size();
    a.push_back(0);
    graph[0].push_back(a[0]);
    for (int i = 0; i < n; i++) {
        graph[a[i]].push_back(a[i + 1]);
    }
    vi c(m + 1), x, y;
    for (int i = 0; i <= m; i++) {
        if (graph[i].size() == 1) {
            c[i] = graph[i][0];
        } else if (graph[i].size() == 2) {
            x.push_back(graph[i][0]), y.push_back(graph[i][1]);
            c[i] = -int(x.size());
        } else if (graph[i].size() == 3) {
            int s1 = -int(x.size() + 1);
            int s2 = s1 - 1, s3 = s1 - 2;
            x.push_back(s2), y.push_back(s3); //s1
            x.push_back(graph[i][0]), y.push_back(s1); //s2
            x.push_back(graph[i][1]), y.push_back(graph[i][2]); //s3
            c[i] = s1;
        } else if (graph[i].size() == 4) {
            int s1 = -int(x.size() + 1);
            int s2 = s1 - 1, s3 = s1 - 2;
            x.push_back(s2), y.push_back(s3); //s1
            x.push_back(graph[i][0]), y.push_back(graph[i][2]); //s2
            x.push_back(graph[i][1]), y.push_back(graph[i][3]); //s3
            c[i] = s1;
        }
    }
    answer(c, x, y);
}
//5 14
//1 2 3 3 2 5 1 1 2 1 4 3 4 3
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...