Submission #995053

# Submission time Handle Problem Language Result Execution time Memory
995053 2024-06-08T11:42:37 Z Nika533 Library (JOI18_library) C++17
0 / 100
1 ms 596 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);
			for (int i=1; i<=n; i++) {
				if (v[i-1]) u[i-1]=0;
			}
			if (x==Query(u)) {
				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;
      |                                     ^
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 596 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 596 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -