Submission #1517731


Source Code Expand

#include <iostream>
#include <vector>
#include <math.h>
#include <map>
#include <stdio.h>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
using namespace std;
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,a) for(int i=0;i<(a);++i)
typedef pair<int, int> P;
typedef pair<pair<P, P>, P>PP;
typedef long long LL;
#define INF LL(1e18)
#define N 1000000000
LL ans;
int search(LL s, LL e, LL i)
{
	char a;
	LL mid = (s + e) / 2;
	cout << "? " << ans + mid * i;
	cin >> a;
	if(mid - s == 1 && a == 'Y')
	{
		return s;
	}
	if(e - mid == 1 && a == 'N')
	{
		return mid;
	}
	return a == 'Y' ? search(s, mid, i): search(mid, e, i);
}
int solve(LL s, LL e, LL i)
{
	char a;
	if(s){
		cout << "? " << s * i + ans;
		cin >> a;
		if(a == 'Y')
	 	 return s; 
	}
	cout << "? " << e * i + ans;
	cin >> a;
	if(a == 'N')
	 return e;
	return search(s, e, i);
}
int main()
{
	for(LL i = LL(1e10); i > 1; i /= 10)
	{
		if(i == LL(1e10))
			ans += solve(1, 9, i) * i;
		else
			ans += solve(0, 9, i) * i;
	}
	ans /= 10;

	for(LL i = LL(1e9); i > 1; i /= 10)
	{
		if(ans % 10)
			break;
		char a;
		cout << "? " << ans + i;
		cin >> a;
		if(a == 'N')
		{
			ans *= 10;
			break;
		}
		ans /= 10;
	}
	cout << "! " << ans << flush;
	return 0;
}

Submission Info

Submission Time
Task E - Awkward Response
User kazu123
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1357 Byte
Status TLE
Exec Time 2103 ms
Memory 596 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 800
Status
TLE × 1
TLE × 40
Set Name Test Cases
Sample 00_example_01.txt
All 00_example_01.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, 39.txt
Case Name Status Exec Time Memory
00_example_01.txt TLE 2103 ms 592 KB
01.txt TLE 2103 ms 592 KB
02.txt TLE 2103 ms 596 KB
03.txt TLE 2103 ms 592 KB
04.txt TLE 2103 ms 592 KB
05.txt TLE 2103 ms 596 KB
06.txt TLE 2103 ms 588 KB
07.txt TLE 2103 ms 592 KB
08.txt TLE 2103 ms 588 KB
09.txt TLE 2103 ms 592 KB
10.txt TLE 2103 ms 592 KB
11.txt TLE 2103 ms 596 KB
12.txt TLE 2103 ms 596 KB
13.txt TLE 2103 ms 592 KB
14.txt TLE 2103 ms 592 KB
15.txt TLE 2103 ms 596 KB
16.txt TLE 2103 ms 588 KB
17.txt TLE 2103 ms 596 KB
18.txt TLE 2103 ms 592 KB
19.txt TLE 2103 ms 596 KB
20.txt TLE 2103 ms 592 KB
21.txt TLE 2103 ms 596 KB
22.txt TLE 2103 ms 596 KB
23.txt TLE 2103 ms 596 KB
24.txt TLE 2103 ms 596 KB
25.txt TLE 2103 ms 596 KB
26.txt TLE 2103 ms 588 KB
27.txt TLE 2103 ms 588 KB
28.txt TLE 2103 ms 592 KB
29.txt TLE 2103 ms 592 KB
30.txt TLE 2103 ms 592 KB
31.txt TLE 2103 ms 592 KB
32.txt TLE 2103 ms 596 KB
33.txt TLE 2103 ms 596 KB
34.txt TLE 2103 ms 592 KB
35.txt TLE 2103 ms 588 KB
36.txt TLE 2103 ms 596 KB
37.txt TLE 2103 ms 592 KB
38.txt TLE 2103 ms 592 KB
39.txt TLE 2103 ms 592 KB