제출 #1246025

#제출 시각아이디문제언어결과실행 시간메모리
1246025nvc2k8도서관 (JOI18_library)C++20
19 / 100
125 ms424 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)
{
    if (N==1)
    {
        vector<int> wow;
        wow.pb(1);
        Answer(wow);
        return;
    }
    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)
        {
            FOR(tmp, 0, N-1) ask[tmp] = 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...