QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#44117#4565. Rarest Insectsfecto_elfilisCompile Error//C++11800b2022-08-13 08:18:222022-08-13 12:27:34

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-08-13 12:27:34]
  • 评测
  • [2022-08-13 08:18:22]
  • 提交

answer

#include "insects.h"
#include <bits/stdc++.h>
using namespace std;

void in (int x) {move_inside(x-1);}
void out (int x) {move_outside(x-1);}
int qry () {return press_button();}
const int NN=2010;
int cnt,sta[NN],fbd[NN];
int min_cardinality (int n) {
	for (int i=1;i<=n;i++) {
		in(x);
		if (qry()>1) {out(x);}
		else {sta[x]=1,cnt++;}
	}
	int l=1,r=n/cnt,nw=cnt;
	while (l<r) {
		int mid=(l+r+1)>>1;
		for (int i=1;i<=n;i++) {
			if (!sta[i]&&!fbd[i]) {
				in(x);
				if (qry()>mid) {out(x);}
				else {sta[x]=2,nw++;}
			}
		}
		if (nw==mid*cnt) {
			for (int i=1;i<=n;i++) {
				if (sta[x]==2) {sta[x]=1;}
			}
			l=mid;
		} else {
			for (int i=1;i<=n;i++) {
				if (!sta[x]) {fbd[x]=1;}
				if (sta[x]==2) {sta[x]=0;}
			}
			r=mid-1;
		}
	}
	return l;
}

Details

implementer.cpp:8:8: warning: inline variables are only available with ‘-std=c++17’ or ‘-std=gnu++17’
    8 | static inline constexpr int kMaxQueries = 40000;
      |        ^~~~~~
answer.code: In function ‘int min_cardinality(int)’:
answer.code:12:20: error: ‘x’ was not declared in this scope
   12 |                 in(x);
      |                    ^
answer.code:21:36: error: ‘x’ was not declared in this scope
   21 |                                 in(x);
      |                                    ^
answer.code:28:41: error: ‘x’ was not declared in this scope
   28 |                                 if (sta[x]==2) {sta[x]=1;}
      |                                         ^
answer.code:33:42: error: ‘x’ was not declared in this scope
   33 |                                 if (!sta[x]) {fbd[x]=1;}
      |                                          ^
answer.code:34:41: error: ‘x’ was not declared in this scope
   34 |                                 if (sta[x]==2) {sta[x]=0;}
      |                                         ^