Submission #995070

# Submission time Handle Problem Language Result Execution time Memory
995070 2024-06-08T11:52:48 Z Nika533 Library (JOI18_library) C++14
100 / 100
356 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){
	if (n==1) {
		vector<int> Q; Q.pb(1);
		Answer(Q);
		return;
	}
	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;
	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; 
			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;
			}
		}
		v[q[ind]-1]=1;
		res.pb(q[ind]);
	}
	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:26:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   26 |  for (int i=1; i<=n; i++) v[i-1]=0; v[st-1]=1;
      |  ^~~
library.cpp:26:37: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   26 |  for (int i=1; i<=n; i++) v[i-1]=0; v[st-1]=1;
      |                                     ^
# Verdict Execution time Memory Grader output
1 Correct 28 ms 344 KB # of queries: 2586
2 Correct 24 ms 344 KB # of queries: 2555
3 Correct 23 ms 344 KB # of queries: 2716
4 Correct 27 ms 344 KB # of queries: 2728
5 Correct 26 ms 344 KB # of queries: 2714
6 Correct 23 ms 344 KB # of queries: 2712
7 Correct 18 ms 344 KB # of queries: 2718
8 Correct 32 ms 344 KB # of queries: 2611
9 Correct 22 ms 344 KB # of queries: 2713
10 Correct 18 ms 344 KB # of queries: 1597
11 Correct 0 ms 344 KB # of queries: 0
12 Correct 0 ms 344 KB # of queries: 4
13 Correct 1 ms 344 KB # of queries: 7
14 Correct 0 ms 344 KB # of queries: 14
15 Correct 1 ms 596 KB # of queries: 99
16 Correct 2 ms 344 KB # of queries: 205
# Verdict Execution time Memory Grader output
1 Correct 28 ms 344 KB # of queries: 2586
2 Correct 24 ms 344 KB # of queries: 2555
3 Correct 23 ms 344 KB # of queries: 2716
4 Correct 27 ms 344 KB # of queries: 2728
5 Correct 26 ms 344 KB # of queries: 2714
6 Correct 23 ms 344 KB # of queries: 2712
7 Correct 18 ms 344 KB # of queries: 2718
8 Correct 32 ms 344 KB # of queries: 2611
9 Correct 22 ms 344 KB # of queries: 2713
10 Correct 18 ms 344 KB # of queries: 1597
11 Correct 0 ms 344 KB # of queries: 0
12 Correct 0 ms 344 KB # of queries: 4
13 Correct 1 ms 344 KB # of queries: 7
14 Correct 0 ms 344 KB # of queries: 14
15 Correct 1 ms 596 KB # of queries: 99
16 Correct 2 ms 344 KB # of queries: 205
17 Correct 311 ms 440 KB # of queries: 18160
18 Correct 319 ms 592 KB # of queries: 17933
19 Correct 356 ms 592 KB # of queries: 18178
20 Correct 272 ms 596 KB # of queries: 16960
21 Correct 233 ms 428 KB # of queries: 15937
22 Correct 303 ms 344 KB # of queries: 18168
23 Correct 297 ms 592 KB # of queries: 18157
24 Correct 119 ms 436 KB # of queries: 8321
25 Correct 340 ms 436 KB # of queries: 17675
26 Correct 264 ms 428 KB # of queries: 16597
27 Correct 92 ms 344 KB # of queries: 8287
28 Correct 321 ms 592 KB # of queries: 18954
29 Correct 321 ms 428 KB # of queries: 18933
30 Correct 349 ms 344 KB # of queries: 18954