QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#186003#5471. Interactive Number GuessingchyenWA 1ms3676kbC++142.1kb2023-09-22 22:50:582023-09-22 22:50:59

Judging History

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

  • [2023-09-22 22:50:59]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3676kb
  • [2023-09-22 22:50:58]
  • 提交

answer

#include<bits/stdc++.h>
#include<bits/extc++.h>
 
#define F first
#define S second
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define mem(x,i) memset((x),(i),sizeof((x)))
 
using namespace std;
//using namespace __gnu_pbds;
using pii = pair<long long,long long>;
using ld = long double;
using ll = long long;
 
mt19937 mtrd(chrono::steady_clock::now().time_since_epoch().count());
 
const int mod = 1000000007;
const int mod2 = 998244353;
const ld PI = acos(-1);
 
#define Bint __int128
#define int long long

namespace DEBUG{ 
	template <typename T, typename T2>
	ostream& operator<<(ostream& os, const pair<T, T2>& pr) {
		os << "( " << pr.first << ", " << pr.second << ")";
		return os;
	}

	template <typename T>
	inline void printv(T l, T r){
		cerr << "DEBUG: [ ";
		for(; l != r; l++)
			cerr << *l << ", ";
		cerr << "]" << endl;
	}
	
	template <typename T>
	inline void _debug(const char* format, T t) {
		cerr << format << '=' << t << endl;
	}
	
	template <class First, class... Rest>
	inline void _debug(const char* format, First first, Rest... rest) {
		while (*format != ',')
			cerr << *format++;
		cerr << '=' << first << ",";
		_debug(format + 1, rest...);
	}

	#define TEST
	#ifdef TEST
	#define debug(...) cerr << "DEBUG: ",_debug(#__VA_ARGS__, __VA_ARGS__)
	#else
	#define debug(...) void(0)
	#define printv(...) void(0)
	#endif
}  // namespace DEBUG

using namespace DEBUG;

/* ----------------------------------------  */
const int LIM = 100000000000000000;
int ans;
int ori;

int ask(int x){
	cout << "query " << x << endl;	
	cin >> x;
	return x;
}
 
int bs(int dec){
	int l = 0, r = 9;
	while(l < r){
		int mid = (l + r + 1) >> 1;
		int x = ask(mid * dec);
		if(x != ori + mid)
			r = mid - 1;
		else
			l = mid;
	}
	return l;
}

void solve(){
	ori = ask(0);	
	for(int i = 10; i; i /= 10){
		ans += (9 - bs(i)) * i;
	}
	cout << "answer " << ans << endl;
}
 
signed main(){
	int t = 1; 
	// cin >> t;
	while(t--)
		solve();
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3676kb

input:

6
11
13
5
11
4
12

output:

query 0
query 50
query 70
query 80
query 5
query 7
query 6
answer 23

result:

wrong answer wrong guess: 23  actual: 123