Submission #746078

# Submission time Handle Problem Language Result Execution time Memory
746078 2023-05-21T11:24:56 Z Rafi22 Mechanical Doll (IOI18_doll) C++14
10 / 100
1000 ms 340 KB
#include <bits/stdc++.h>
#include "doll.h"

using namespace std;

#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define ll long long
ll mod=1000000007;
int inf=1000000007;
ll infl=1000000000000000007;

const int N=200007;

int it,n;

int x[N+20];
int y[N+20];
bool state[N+20];
bool kon[N+20];

void build(int v,int l,int r)
{
    if(l+1==r)
    {
        kon[v]=1;
        if(n==l) x[v]=1;

        return ;
    }
    it++;
    y[v]=-it;
    build(it,l,(l+r)/2);
    if(n>(l+r)/2)
    {
        it++;
        x[v]=-it;
        build(it,(l+r)/2+1,r);
    }
    else x[v]=1;
}

void push(int v,int k)
{
    state[v]^=1;
    if(state[v])
    {
        if(kon[v])
        {
            if(x[v]==1) push(1,k);
            else x[v]=k;
        }
        else push(-x[v],k);
    }
    else
    {
        if(kon[v])
        {
            if(y[v]==1) push(1,k);
            else y[v]=k;
        }
        else push(-y[v],k);
    }
}

void create_circuit(int m,vector<int>a)
{
    vector<int>c(m+1);
    n=sz(a);
    c[0]=a[0];
    for(int i=1;i<=m;i++) c[i]=-1;
    int p=1;
    while(p<n) p*=2;
    it++;
    build(1,1,p);
    for(int i=0;i<n-1;i++) push(1,a[i+1]);
    push(1,0);
    vector<int>X,Y;
    for(int i=1;i<=it;i++) X.pb(x[i]);
    for(int i=1;i<=it;i++) Y.pb(y[i]);
    answer(c,X,Y);
}

/*int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    create_circuit(4,{1,2,1,3});

    return 0;
}*/
# Verdict Execution time Memory Grader output
1 Execution timed out 1047 ms 340 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1047 ms 340 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1047 ms 340 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 312 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
6 Correct 0 ms 312 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1063 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1063 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -