답안 #875357

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
875357 2023-11-19T08:58:35 Z willychan Shopping (JOI21_shopping) C++17
0 / 100
8 ms 380 KB
#include "Anna.h"
#include <vector>
using namespace std;
namespace {

int triL[9];
int triR[9];
const int B = 51;
int n, l, r;
int count;
int BTnum = 0;
int RL[B];
int RR[B];
}  // namespace
void InitA(int N, int L, int R) {
  BTnum=0;
  count=0;
  for(int i=0;i<9;i++){
  	triL[i]=0;
  	triR[i]=0;
  }
  for(int i=0;i<B;i++){
  	RL[i]=0;
	RR[i]=0;
  }
  n = N;
  l = L;
  r = R;
  int bl = l/B;
  int br = r/B;
  for(int i=8;i>=0;i--){
  	triL[i] = (bl%3)-1;
	triR[i] = (br%3)-1;
	bl/=3;
	br/=3;
  }
}

void ReceiveA(bool x) {
	count++;			
	if(count<=18){
		int i = count-1;
		if(count<=9){
			if(triL[i]>=0) SendA(triL[i]==1);
		}else{
			if(triR[i]>=0) SendA(triR[i]==1);
		}
	}else{
		if(count>=19 && count<=38){
			BTnum<<=1;	
			BTnum+=x;
		}else{
			if(count<=1058){
				RL[((count-39)/20)]*=2;	
				RL[((count-39)/20)]+=x;
			}else{
				RR[((count-1059)/20)]*=2;	
				RR[((count-1059)/20)]+=x;
			}
		}
	}
	if(count==2078) Answer();
}

int Answer() {
	int minn = 1e9;
	minn = min(minn,BTnum);
	int rl = l%B;		
	int rr = r%B;
	if(l/B==r/B){
		for(int i=rl;i<=rr;i++) minn = min(minn,RL[i]);
	}else{
		for(int i=rl;i<B;i++) minn = min(minn,RL[i]);
		for(int i=B-1;i>=rr;i--) minn = min(minn,RR[i]);
	}
	return minn;
}
#include "Bruno.h"
#include <vector>
using namespace std;
namespace {
const int B = 51;
int n;
int arr[1000000];
int count;
int ans = 0;
bool FunctionExample(bool P) {
  return !P;
}

}  // namespace

void InitB(int N, std::vector<int> P) {
  n = N;
  for(int i = 0; i < N; i++) {
    arr[i] = P[i];
  }
  int LB = 0;
  int RB = 0;
  for(int i=0;i<9;i++){
  	ans = -1;	
	SendB(1);
	int tri = ans+1;
	LB*=3;
	LB+=tri;
  }
  for(int i=0;i<9;i++){
  	ans = -1;
	SendB(1);
	int tri = ans+1;
	RB*=3;
	RB+=tri;
  }
  int l = B*(LB+1);
  int r = B*(RB)-1;
  int BTnum = 1e9;
  for(int i=l;i<=r && i<n;i++) BTnum = min(BTnum,arr[i]);
  for(int i=19;i>=0;i--){
  	SendB((BTnum>>i)&1);
  }
  for(int i=0;i<B;i++){
  	int loc = i+B*(LB);
	int G = (1<<20)-1;
	if(loc<n) G = arr[loc];
	for(int i=19;i>=0;i--){
		SendB((G>>i)&1);
	}
  }
  for(int i=0;i<B;i++){
  	int loc = i+B*(RB);
	int G = (1<<20)-1;
	if(loc<n) G = arr[loc];
	for(int i=19;i>=0;i--){
		SendB((G>>i)&1);
	}
  }
}

void ReceiveB(bool y) {
	ans = (int)y;
}

Compilation message

Bruno.cpp:10:6: warning: 'bool {anonymous}::FunctionExample(bool)' defined but not used [-Wunused-function]
   10 | bool FunctionExample(bool P) {
      |      ^~~~~~~~~~~~~~~
Bruno.cpp:8:5: warning: '{anonymous}::count' defined but not used [-Wunused-variable]
    8 | int count;
      |     ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 332 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 332 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 380 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -