답안 #875359

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

int triL[9];
int triR[9];
const int B = 51;
int n, l, r;
int count;
int BTnum = 0;
int BTind = 0;
int RL[B];
int RR[B];
}  // namespace
void InitA(int N, int L, int R) {
  BTnum=0;
  BTind = 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>=39 && count<=58){
			BTind<<=1;
			BTind+=x;
		}else{
			if(count<=1078){
				RL[((count-59)/20)]*=2;	
				RL[((count-59)/20)]+=x;
			}else{
				RR[((count-1079)/20)]*=2;	
				RR[((count-1079)/20)]+=x;
			}
		}
	}
}

int Answer() {
	pair<int,int> minn = {1e9,-1};
	minn = min(minn,{BTnum,BTind});
	/*
	for(int i=0;i<B;i++) cout<<RL[i]<<" ";
	cout<<"L\n";
	for(int i=0;i<B;i++) cout<<RL[i]<<" ";
	cout<<"R\n";
	*/
	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],B*(l/B)+i});
	}else{
		for(int i=rl;i<B;i++) minn = min(minn,{RL[i],B*(l/B)+i});
		for(int i=B-1;i>=rr;i--) minn = min(minn,{RR[i],B*(r/B)+i});
	}
	return minn.second;
}
#include "Bruno.h"
#include <vector>
#include<iostream>
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;
  pair<int,int> BTnum = {1e9,1e9};
  for(int i=l;i<=r && i<n;i++) BTnum = min(BTnum,{arr[i],i});
  for(int i=19;i>=0;i--){
  	SendB((BTnum.first>>i)&1);
  }
  for(int i=19;i>=0;i--){
  	SendB((BTnum.second>>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:11:6: warning: 'bool {anonymous}::FunctionExample(bool)' defined but not used [-Wunused-function]
   11 | bool FunctionExample(bool P) {
      |      ^~~~~~~~~~~~~~~
Bruno.cpp:9:5: warning: '{anonymous}::count' defined but not used [-Wunused-variable]
    9 | int count;
      |     ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 664 KB Output is correct
2 Correct 9 ms 664 KB Output is correct
3 Correct 11 ms 664 KB Output is correct
4 Correct 10 ms 664 KB Output is correct
5 Correct 8 ms 664 KB Output is correct
6 Incorrect 8 ms 332 KB Wrong Answer [2]
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 664 KB Output is correct
2 Correct 9 ms 664 KB Output is correct
3 Correct 11 ms 664 KB Output is correct
4 Correct 10 ms 664 KB Output is correct
5 Correct 8 ms 664 KB Output is correct
6 Incorrect 8 ms 332 KB Wrong Answer [2]
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 588 KB Wrong Answer [2]
2 Halted 0 ms 0 KB -