Submission #1060228

#TimeUsernameProblemLanguageResultExecution timeMemory
1060228TlenekWodoruMechanical Doll (IOI18_doll)C++14
100 / 100
53 ms13808 KiB
#include<bits/stdc++.h>
#include "doll.h"
using namespace std;
vector<pair<int,int>>U;
int Graf[2100009][2];
int h=1;
void F(int n)
{
    if(n==2)
    {
        U.push_back({1,0});
        U.push_back({1,1});
        return;
    }
    F((n+1)/2);
    vector<pair<int,int>>A,B;
    if(n%2==0)
    {
        for(auto[v,u] : U)
        {
            h++;
            Graf[v][u]=h;
            A.push_back({h,0});
            B.push_back({h,1});
        }
    }
    else
    {
        bool CzyPierwszy=1;
        for(auto[v,u] : U)
        {
            h++;
            Graf[v][u]=h;
            if(CzyPierwszy)
            {
                CzyPierwszy=0;
                Graf[h][1]=1;
                A.push_back({h,0});
                B.push_back({-1,-1});
            }
            else
            {
                A.push_back({h,0});
                B.push_back({h,1});
            }
        }
    }
    U.clear();
    for(auto xd : A)
    {
        U.push_back(xd);
    }
    for(auto xd : B)
    {
        if(xd.first==-1){continue;}
        U.push_back(xd);
    }
}
void create_circuit(int M, vector<int>A)
{
    A.push_back(0);
    F(A.size());
    vector<int>C(M+1,-1);
    vector<int>X(h),Y(h);
    for(int i=1;i<=h;i++)
    {
        X[i-1]=-Graf[i][0];
        Y[i-1]=-Graf[i][1];
    }
    for(int i=0;i<(int)U.size();i++)
    {
        if(U[i].second==0)
        {
            X[U[i].first-1]=A[i];
        }
        else
        {
            Y[U[i].first-1]=A[i];
        }
    }
    answer(C, X, Y);
}

Compilation message (stderr)

doll.cpp: In function 'void F(int)':
doll.cpp:19:17: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   19 |         for(auto[v,u] : U)
      |                 ^
doll.cpp:30:17: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   30 |         for(auto[v,u] : U)
      |                 ^
#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...