結果

問題 No.3246 80% Accuracy Calculator
ユーザー 沙耶花
提出日時 2025-08-22 22:47:09
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 1,290 bytes
コンパイル時間 3,812 ms
コンパイル使用メモリ 257,688 KB
実行使用メモリ 26,668 KB
平均クエリ数 35.26
最終ジャッジ日時 2025-08-22 22:47:21
合計ジャッジ時間 11,704 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 2 RE * 41
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int query(char)’:
main.cpp:26:1: warning: control reaches end of non-void function [-Wreturn-type]
   26 | }
      | ^

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000005
#define Inf64 1000000000000000001LL
int query(char c){
	map<int,int> mp;
	rep(i,10){
		cout<<"? "<<c<<endl;
		int res;
		cin>>res;
		assert(res!=-1);
		mp[res]++;
	}
	int ma = 0;
	for(auto a:mp){
		ma = max(ma,a.second);
	}
	for(auto a:mp){
		if(ma==a.second)return a.first;
	}
}
int add(char a,char b,char c){
	cout<<"+ "<<a<<' '<<b<<' '<<c<<endl;
	int z;
	cin>>z;
	assert(z!=-1);
	return z;
}
int main(){
	int x = query('A');
	int y = query('B');
	int curx = x;
	while(true){
		add('A','A','B');
		if(query('B')==curx*2)break;
	}
	curx *= 2;
	char cx,ans,trash;
	int cans = 0;
	if(y%2==1){
		ans = 'A';
		trash = 'C';
		cx = 'B';
		cans = x;
	}
	else{
		ans = 'C';
		cx = 'B';
		trash = 'A';
	}
	y /= 2;
	while(y!=0){
		cout<<y<<endl;
		if(y%2==1){
			cans += curx;
			while(true){
			//	cout<<"fuga"<<curx<<endl;
				add(cx,ans,trash);
				if(query(trash)==cans)break;
			}
			swap(trash,ans);
		}
		y /= 2;
		while(true){
			//cout<<"hoge"<<curx<<endl;
			add(cx,cx,trash);
			if(query(trash)==curx*2)break;
		}
		swap(cx,trash);
		curx *= 2;
	}
	cout<<"! "<<ans<<endl;
}
0