Submission #286139

# Submission time Handle Problem Language Result Execution time Memory
286139 2020-08-30T07:15:05 Z kartel Mechanical Doll (IOI18_doll) C++14
16 / 100
121 ms 11908 KB
#include <bits/stdc++.h>
//#include "grader.cpp"
#include "doll.h"
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define in(x) freopen(x, "r", stdin)
#define out(x) freopen(x, "w", stdout)
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("no-stack-protector")
#define F first
#define S second
#define pb push_back
#define N +100500
//#define M ll(1e9 + 7)
#define sz(x) (int)x.size()
#define re return
#define oo ll(1e9)
#define el '\n'
#define Max_A int(1e9)
//#define el endl
#define pii pair <int, int>
#define piii pair <int, pair <int, int> >
#define psi pair <string, int>
#define err ld(1e-9)
#define Max_S int(3e6)
#define last(x) (x).back()
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define arr_all(x, n) (x + 1), (x + 1 + n)
#define vi vector<int>
using namespace std;
//using namespace __gnu_pbds;
//typedef tree <int, null_type, less_equal <int> , rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;

void create_circuit(int M, vector<int> A)
{
    vi X, Y, C;
    vi g[M + 1];
    int i;
    int n = sz(A);

    C.resize(M + 1);

    for (i = 0; i < sz(A) - 1; i++)
        g[A[i]].pb(A[i + 1]);

    i = 1;
    while (i < n && A[i] == A[i - 1])
        i++;

    if (i == n)
    {
        if (sz(A) == 2)
        {
            C[A[0]] = -1;
            X.pb(1);
            Y.pb(0);
        }
        else if (sz(A) == 4)
        {
            C[A[0]] = -1;
            X.pb(-2); X.pb(1); X.pb(1);
            Y.pb(-3); Y.pb(1); Y.pb(0);
        }
        else
        if (sz(A) == 1)
            A[1] = C[0];
            else
            {
                C[A[0]] = -1;
                X.pb(1);
                Y.pb(-2);
                X.pb(-1);
                Y.pb(0);
//                X.pb(1);
//                Y.pb(0);
            }
        C[0] = A[0];
        answer(C, X, Y);
        return;
    }
    A.pb(0);
    g[A[n - 1]].pb(0);

    for (i = 1; i <= M; i++)
    {
        if (!sz(g[i]))
            continue;

        if (sz(g[i]) == 1)
            C[i] = last(g[i]);
        else
        {
            if (sz(g[i]) == 2)
            {
                C[i] = -(sz(X) + 1);
                X.pb(g[i][0]);
                Y.pb(g[i][1]);
            }
            else
            {
                C[i] = -(sz(X) + 1);

                X.pb(-(sz(X) + 2));
                Y.pb(-(sz(X) + 2));


                if (sz(g[i]) == 3)
                {
                    X.pb(g[i][0]);
                    Y.pb(-sz(Y));
                    X.pb(g[i][1]);
                    Y.pb(g[i][2]);
                }
                else
                {
                    X.pb(g[i][0]);
                    Y.pb(g[i][2]);
                    X.pb(g[i][1]);
                    Y.pb(g[i][3]);
                }
            }
        }
    }

    C[0] = A[0];

//    for (auto x : C)
//        cout << x << " ";
//    cout << el;
//
//    for (auto x : X)
//        cout << x << " ";
//    cout << el;
//
//    for (auto x : Y)
//        cout << x << " ";
//    cout << el;

    answer(C, X, Y);
}

//int main()
//{
//    srand(time(0));
//    cout.precision(3);
//    cout << fixed;
//    ios_base::sync_with_stdio(0);
//    iostream::sync_with_stdio(0);
//    ios::sync_with_stdio(0);
//    cin.tie(NULL);
//    cout.tie(NULL);
//
//
////    in("input.txt");
////    out("output.txt");
//
//
//}
/*
4 4
0110
0000
1101
1100
*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 31 ms 6344 KB Output is correct
3 Correct 30 ms 5124 KB Output is correct
4 Correct 2 ms 204 KB Output is correct
5 Correct 19 ms 3788 KB Output is correct
6 Correct 50 ms 7740 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 31 ms 6344 KB Output is correct
3 Correct 30 ms 5124 KB Output is correct
4 Correct 2 ms 204 KB Output is correct
5 Correct 19 ms 3788 KB Output is correct
6 Correct 50 ms 7740 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 55 ms 7736 KB Output is correct
9 Correct 73 ms 8728 KB Output is correct
10 Correct 92 ms 11908 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 31 ms 6344 KB Output is correct
3 Correct 30 ms 5124 KB Output is correct
4 Correct 2 ms 204 KB Output is correct
5 Correct 19 ms 3788 KB Output is correct
6 Correct 50 ms 7740 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 55 ms 7736 KB Output is correct
9 Correct 73 ms 8728 KB Output is correct
10 Correct 92 ms 11908 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 105 ms 11508 KB Output is correct
15 Correct 51 ms 6712 KB Output is correct
16 Correct 107 ms 8896 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 121 ms 10820 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB wrong motion
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB wrong motion
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB wrong motion
2 Halted 0 ms 0 KB -