제출 #766934

#제출 시각아이디문제언어결과실행 시간메모리
766934ParsaS도서관 (JOI18_library)C++17
100 / 100
265 ms336 KiB
#include<bits/stdc++.h>
#include <cstdio>
#include <vector>
#include "library.h"
using namespace std;
const int N = 1000 + 5;
void Solve(int n)
{
	vector<int> res(n);
    if (n == 1) {
        res[0] = 1;
        Answer(res);
        return;
    }

    for (int i = 0; i < n; i++) {
	    vector<int> M(n, 1);
        assert(M[0]);
        M[i] = 0;
        int x = Query(M);
        if (x == 1)
            res[0] = i;
    }
    vector<int> A(n, 1);

    A[res[0]] = 0;
    for (int i = 1; i < n; i++) {
        vector<int> B(n);
        int cnt = 0;
        for (int j = 0; j < n; j++)
            B[j] = A[j], cnt += B[j];
        while (cnt > 1) {
            int c = 0;
	        vector<int> M(n, 0);
            for (int j = 0; j < n; j++) {
                if (c < cnt / 2 && B[j])
                    M[j] = 1, c++;
            }
            int x = Query(M);
            M[res[i - 1]] = 1;
            int y = Query(M);
            int k = 0;
            vector<int> C(n);
            if (x == y) {
                c = 0;
                for (int j = 0; j < n; j++) {
                    if (c < cnt / 2 && B[j])
                        C[j] = 1, k++;
                    c += B[j];
                }
            }
            else {
                c = 0;
                for (int j = 0; j < n; j++) {
                    if (c >= cnt / 2 && B[j])
                        C[j] = 1, k++;
                    c += B[j];
                }
            }
            B = C;
            cnt = k;
        }
        for (int j = 0; j < n; j++)
            if (B[j])
                res[i] = j, A[j] = 0;
    }
    for (int j = 0; j < n; j++)
        ++res[j];

	Answer(res);
}

컴파일 시 표준 에러 (stderr) 메시지

library.cpp: In function 'void Solve(int)':
library.cpp:67:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   67 |     for (int j = 0; j < n; j++)
      |     ^~~
library.cpp:70:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   70 |  Answer(res);
      |  ^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...