Submission #1246022

#TimeUsernameProblemLanguageResultExecution timeMemory
1246022nvc2k8Library (JOI18_library)C++20
0 / 100
54 ms420 KiB
#include <bits/stdc++.h>
#define TASK "kajsdkjd"
#include "library.h"
#define endl '\n'
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define BIT(i,x) (((i)>>(x))&1)
#define FOR(i,a,b) for(int i = (a); i<=(b); i++)
#define FORD(i,a,b) for(int i = (a); i>=(b); i--)
#define all(C) C.begin(), C.end()
using namespace std;
using ll = long long;
using pii = pair<int,int>;
const int INT_LIM = 2147483647;
const ll LL_LIM = 9223372036854775807;
template <typename X> bool minimize(X &x, const X &y) {if (x>y){x = y; return true;}return false;}
template <typename X> bool maximize(X &x, const X &y) {if (x<y){x = y; return true;}return false;}
///------------------------------------------///

vector<int> candidate;
vector<int> ans;

void eraseVal(int val) {
    auto it = find(candidate.begin(), candidate.end(), val);
    if (it != candidate.end()) {
    candidate.erase(it);
    }
}

void Solve(int N)
{
    ans.clear();
    candidate.clear();
    vector<int> ask;
    FOR(i, 1, N)
    {
        ask.pb(1);
        candidate.pb(i);
    }

    FOR(i, 1, N)
    {
        ask[i-1] = 0;
        if (Query(ask)==1)
        {
            ans.pb(i); break;
        }
        ask[i-1] = 1;
    }

    eraseVal(ans[0]);

    FOR(i, 2, N)
    {
        int nx = -1;
        for (auto t:candidate)
        {
            fill(all(ask), 0);
            for (auto j:ans) ask[j-1] = 1;
            ask[t-1] = 1;
            if (Query(ask)==1)
            {
                nx = t;
                break;
            }
        }
        ans.pb(nx);
        eraseVal(nx);
    }

    Answer(ans);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...