Submission #436102

# Submission time Handle Problem Language Result Execution time Memory
436102 2021-06-24T08:50:32 Z LouayFarah Library (JOI18_library) C++14
0 / 100
303 ms 840 KB
#include "bits/stdc++.h"
#include "library.h"

using namespace std;

#define pb push_back

int Query(const vector<int> &m);
void Answer(const vector<int> &res);

void Solve(int n)
{
    vector<int> m(n);
    vector<int> adj[n+1];
    for(int i = 1; i<=n; i++)
    {
        for(int j = i+1; j<=n; j++)
        {
            m.assign(n, 0);
            m[i-1] = 1, m[j-1] = 1;

            int curr  = Query(m);

            if(curr==2)
            {
                adj[i].pb(j);
                adj[j].pb(i);
            }
        }
    }

    vector<int> res(n, 0);

    for(int i = 1; i<=n; i++)
    {
        if((int)adj[i].size()==1)
        {
            res[0] = i;
            break;
        }
    }
    for(int i = 1; i<=n; i++)
    {
        if((int)adj[i].size()==1&&res[0]!=i)
        {
            res[n-1] = i;
            break;
        }
    }

    for(int i = 1; i<n-1; i++)
    {
        int x = res[i-1];
        if((int)adj[x].size()==1)
        {
            res[i] = adj[x][0];
        }
        else
        {
            if(adj[x][0]==res[i-2])
                res[i] = adj[x][1];
            else
                res[i] = adj[x][0];
        }
    }

    Answer(res);
    return;
}
# Verdict Execution time Memory Grader output
1 Runtime error 303 ms 840 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 303 ms 840 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -