답안 #441316

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
441316 2021-07-04T23:44:06 Z Agnimandur 도서관 (JOI18_library) C++17
0 / 100
13 ms 200 KB
#include <bits/stdc++.h>
#include "library.h"

#define ll long long
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
#define vl vector<long long>
#define pii pair<int, int>
#define pll pair<ll,ll>
#define add push_back
using namespace std;

vi build(vi &alive, int i, int j) {
    int N = sz(alive);
    vi ret;
    ret.assign(N,0);
    int ind = 0;

    for (int i = 0; i < N; i++) {
        if (alive[i]==1 && (i <= ind && ind <= j)) {
            ret[i] = 1;
            ind++;
        }
    }
    return ret;
}

void Solve(int N) {

    int end = -1;
    for (int i = 0; i < N; i++) {
        vi nums;
        nums.assign(N,1);
        nums[i] = 0;
        int A = Query(nums);
        if (A==1) {
            end = i;
            break;
        }
    }

    vi ans;
    ans.add(end);

    vi alive;
    alive.assign(N,1);
    alive[end] = 0;

    for (int s = N-1; s >= 1; s--) {
        int lo = 0;
        int hi = s-1;
        int last = ans[sz(ans)-1];

        while (lo < hi) {
            int m = (lo+hi)/2;
            vi M = build(alive,lo,m);
            int x = 1;
            if (lo<m) x = Query(M);
            M[last] = 1;
            int y = Query(M);
            if (y==x) {
                hi = m;
            } else {
                lo = m+1;
            }
        }
        ans.add(lo);
        alive[lo] = 0;
    }

    for (int i = 0; i < N; i++)
        ans[i]++;
	Answer(ans);
}

Compilation message

library.cpp: In function 'void Solve(int)':
library.cpp:72:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   72 |     for (int i = 0; i < N; i++)
      |     ^~~
library.cpp:74:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   74 |  Answer(ans);
      |  ^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 13 ms 200 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 13 ms 200 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -