답안 #995061

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
995061 2024-06-08T11:48:46 Z Nika533 도서관 (JOI18_library) C++14
0 / 100
1 ms 344 KB
#pragma gcc diagnostic "-std=c++1z"
#include <bits/stdc++.h>
#include "library.h"
#define pb push_back
#define f first
#define s second
#define MOD 1000000007
#define pii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
using namespace std;
int m,T,k;

void Solve(int n){
	vector<int> v(n,1);
	int st;
	for (int i=1; i<=n; i++) {
		v[i-1]=0; if (Query(v)==1) st=i;
		v[i-1]=1;
	}
	for (int i=1; i<=n; i++) v[i-1]=0; v[st-1]=1;
	cout<<st<<endl;
	vector<int> res; res.pb(st);
	for (int i=2; i<=n; i++) {
		vector<int> q;
		for (int i=1; i<=n; i++) {
			if (v[i-1]==0) q.pb(i);
		}
		int l=0,r=q.size()-1,ind=-1;
		while (l<=r) {
			vector<int> u=v;
			int mid=(l+r)/2;
//			cout<<"MID "<<mid<<endl; 
			for (int j=0; j<=mid; j++) {
				u[q[j]-1]=1;
			}
			int x=Query(u);
			u[res.back()-1]=0;
			int y=Query(u);
			if ((i!=2 && x==y-1) || (i==2 && x==y)) {
				ind=mid; r=mid-1;
			}
			else {
				l=mid+1;
			}
		}
//		cout<<"IND "<<ind<<endl;
		v[q[ind]-1]=1;
		res.pb(q[ind]);
		cout<<q[ind]<<endl;
	}
	Answer(res);
}

Compilation message

library.cpp:1: warning: ignoring '#pragma gcc diagnostic' [-Wunknown-pragmas]
    1 | #pragma gcc diagnostic "-std=c++1z"
      | 
library.cpp: In function 'void Solve(int)':
library.cpp:21:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   21 |  for (int i=1; i<=n; i++) v[i-1]=0; v[st-1]=1;
      |  ^~~
library.cpp:21:37: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   21 |  for (int i=1; i<=n; i++) v[i-1]=0; v[st-1]=1;
      |                                     ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -