QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#47578#4565. Rarest InsectsCrysfly0 68ms4036kbC++111.4kb2022-09-10 14:47:192022-09-10 14:47:19

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-09-10 14:47:19]
  • 评测
  • 测评结果:0
  • 用时:68ms
  • 内存:4036kb
  • [2022-09-10 14:47:19]
  • 提交

answer

#include "insects.h"
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define ll long long
using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define pb push_back
typedef pair<int,int>pii;
typedef vector<int>vi;

#define maxn 1000005
#define inf 0x3f3f3f3f

int n,siz; 
vi in,out;
int cnt;

vector<bool>now,lst;
void move_in(int i){now[i]=1;}
void move_out(int i){now[i]=0;}
map<vector<bool>,int>mp;
int query(){
	if(mp.count(now))return mp[now];
	For(i,0,n-1){
		if(now[i]&&!lst[i])move_inside(i);
		if(!now[i]&&lst[i])move_outside(i);
		lst[i]=now[i];
	}
	return mp[now]=press_button();
}

bool chk(int x)
{
	vi tin,tout; int c=0;
	for(auto u:out){
		if(tin.size()==x*siz){tout.pb(u);continue;}
		move_in(u);
		++c;
		if(c<=x||query()<=x+cnt)tin.pb(u);
		else tout.pb(u),move_out(u);
	}
	if(tin.size()==x*siz){
		out=tout;
		cnt+=x; return 1;
	}else{
		for(auto u:tin) move_out(u);
		out=tin; return 0;
	}
}
int min_cardinality(int nn)
{
	n=nn;
	now.resize(n),lst=now;
	For(i,0,n-1){
		move_in(i);
		if(query()==1)in.pb(i);
		else out.pb(i),move_out(i);
	}
	if(in.size()==n)return 1;
	int l=1,r=n/in.size(),res=1; cnt=0; siz=in.size();
	while(l<=r){
		int mid=(l+r+1)/2;
		if(chk(mid-l+1))l=mid+1,res=mid;
		else r=mid-1;
	}return res;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 10
Accepted
time: 3ms
memory: 3688kb

input:

6
1
1
1
2
2
2
3
2

output:

8
0 0
8
2
8
0 1
8
2
8
0 2
8
2
8
0 3
8
2
8
1 3
8
0 4
8
2
8
1 4
8
0 5
8
2
8
0 3
8
0 4
8
2
8
1 5
8
2
8
3 1

result:

ok 

Test #2:

score: -10
Wrong Answer
time: 1ms
memory: 3784kb

input:

2
1
2

output:

8
0 0
8
2
8
0 1
8
2
8
3 1

result:

wrong answer Wrong answer.

Subtask #2:

score: 0
Wrong Answer

Test #24:

score: 0
Wrong Answer
time: 68ms
memory: 4036kb

input:

1000
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 0
8
2
8
0 1
8
2
8
1 1
8
0 2
8
2
8
1 2
8
0 3
8
2
8
1 3
8
0 4
8
2
8
1 4
8
0 5
8
2
8
1 5
8
0 6
8
2
8
1 6
8
0 7
8
2
8
1 7
8
0 8
8
2
8
1 8
8
0 9
8
2
8
1 9
8
0 10
8
2
8
1 10
8
0 11
8
2
8
1 11
8
0 12
8
2
8
1 12
8
0 13
8
2
8
1 13
8
0 14
8
2
8
1 14
8
0 15
8
2
8
1 15
8
0 16
8
2
8
1 16
8
0 17
8
2
8
1 17
8
...

result:

wrong answer Wrong answer.

Subtask #3:

score: 0
Wrong Answer

Test #43:

score: 0
Wrong Answer
time: 0ms
memory: 3788kb

input:

2
1
2

output:

8
0 0
8
2
8
0 1
8
2
8
3 1

result:

wrong answer Wrong answer.