AtCoder Regular Contest 070

Submission #1357060

Source codeソースコード

#include <iostream>
#include <cstdio>
#include <cstring>
#include <stack>
using namespace std;

const int maxn = 10010;
stack<int> s;
int ans[maxn];

bool ask(int p, int q)
{
	string str;
	cout<<"? "<<p<<" "<<q<<endl;
	cin>>str;
	if (str == "Y") return true;
	else return false;
}
	
int main()
{
	int a,b,n;
	cin>>a>>b;
	n = a+b;
	if (b >= a) 
	{
		cout<<"Impossible"<<endl;
		return 0;
	}
	int need = b+1, honest;
	for (int i=0;i<n;i++)
	{
		if (s.empty()) s.push(i);
		else 
		{
			if (ask(s.top(),i)) s.push(i);
			else s.pop(), need--;
		}
		if ((int)s.size() >= need)
		{
			honest = s.top();
			break;
		}
	}
	
	for (int i=0;i<n;i++)
	{
		if (ask(honest,i)) ans[i] = 1;
		else ans[i] = 0;
	}
	cout<<"! ";
	for (int i=0;i<n;i++) cout<<ans[i];
	cout<<endl;
	return 0;
}

Submission

Task問題 F - HonestOrUnkind
User nameユーザ名 Gabriel
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 AC
Score得点 1300
Source lengthソースコード長 829 Byte
File nameファイル名
Exec time実行時間 300 ms
Memory usageメモリ使用量 724 KB

Test case

Set

Set name Score得点 / Max score Cases
All 1300 / 1300 000.txt,001.txt,002.txt,003.txt,004.txt,005.txt,006.txt,007.txt,008.txt,009.txt,010.txt,011.txt,012.txt,013.txt,014.txt,015.txt,016.txt,017.txt,018.txt,019.txt,020.txt,021.txt,022.txt,023.txt,024.txt,025.txt,026.txt,027.txt,028.txt,029.txt,030.txt,031.txt,032.txt,033.txt,034.txt,035.txt,036.txt,037.txt,038.txt,039.txt,040.txt,041.txt,042.txt,043.txt,044.txt,045.txt,046.txt,047.txt,048.txt,049.txt,050.txt,051.txt,052.txt,053.txt,054.txt,055.txt,056.txt,057.txt,058.txt,059.txt,060.txt,061.txt,062.txt,063.txt,064.txt,065.txt,066.txt,067.txt,068.txt,069.txt,070.txt,071.txt,072.txt,073.txt,074.txt,075.txt,076.txt,077.txt,078.txt,079.txt,080.txt,081.txt,082.txt,083.txt,084.txt,085.txt,086.txt,087.txt,088.txt,089.txt,090.txt,091.txt,092.txt,093.txt,094.txt,095.txt,096.txt,097.txt,098.txt,099.txt,100.txt,101.txt,102.txt,103.txt,104.txt,105.txt,106.txt,107.txt,108.txt,109.txt,110.txt,111.txt,112.txt,113.txt,114.txt,115.txt,116.txt,117.txt,118.txt,119.txt,120.txt,121.txt,122.txt,123.txt,124.txt,125.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
000.txt AC 3 ms 720 KB
001.txt AC 3 ms 592 KB
002.txt AC 3 ms 720 KB
003.txt AC 3 ms 720 KB
004.txt AC 3 ms 724 KB
005.txt AC 3 ms 720 KB
006.txt AC 3 ms 720 KB
007.txt AC 3 ms 720 KB
008.txt AC 3 ms 716 KB
009.txt AC 3 ms 720 KB
010.txt AC 15 ms 720 KB
011.txt AC 294 ms 720 KB
012.txt AC 68 ms 716 KB
013.txt AC 3 ms 724 KB
014.txt AC 3 ms 724 KB
015.txt AC 3 ms 712 KB
016.txt AC 3 ms 720 KB
017.txt AC 3 ms 720 KB
018.txt AC 3 ms 716 KB
019.txt AC 3 ms 644 KB
020.txt AC 3 ms 648 KB
021.txt AC 3 ms 720 KB
022.txt AC 3 ms 720 KB
023.txt AC 14 ms 724 KB
024.txt AC 289 ms 720 KB
025.txt AC 76 ms 720 KB
026.txt AC 3 ms 720 KB
027.txt AC 3 ms 720 KB
028.txt AC 3 ms 724 KB
029.txt AC 3 ms 720 KB
030.txt AC 3 ms 720 KB
031.txt AC 3 ms 720 KB
032.txt AC 3 ms 720 KB
033.txt AC 3 ms 720 KB
034.txt AC 3 ms 720 KB
035.txt AC 3 ms 720 KB
036.txt AC 15 ms 588 KB
037.txt AC 281 ms 720 KB
038.txt AC 73 ms 720 KB
039.txt AC 3 ms 720 KB
040.txt AC 3 ms 688 KB
041.txt AC 3 ms 720 KB
042.txt AC 3 ms 720 KB
043.txt AC 3 ms 720 KB
044.txt AC 3 ms 716 KB
045.txt AC 3 ms 592 KB
046.txt AC 3 ms 724 KB
047.txt AC 3 ms 720 KB
048.txt AC 3 ms 720 KB
049.txt AC 15 ms 592 KB
050.txt AC 300 ms 724 KB
051.txt AC 74 ms 720 KB
052.txt AC 3 ms 720 KB
053.txt AC 3 ms 724 KB
054.txt AC 3 ms 716 KB
055.txt AC 3 ms 720 KB
056.txt AC 3 ms 720 KB
057.txt AC 3 ms 720 KB
058.txt AC 3 ms 684 KB
059.txt AC 3 ms 720 KB
060.txt AC 3 ms 720 KB
061.txt AC 3 ms 720 KB
062.txt AC 15 ms 592 KB
063.txt AC 287 ms 716 KB
064.txt AC 73 ms 720 KB
065.txt AC 3 ms 720 KB
066.txt AC 3 ms 720 KB
067.txt AC 3 ms 644 KB
068.txt AC 3 ms 720 KB
069.txt AC 3 ms 720 KB
070.txt AC 3 ms 720 KB
071.txt AC 3 ms 684 KB
072.txt AC 3 ms 724 KB
073.txt AC 3 ms 720 KB
074.txt AC 3 ms 716 KB
075.txt AC 15 ms 592 KB
076.txt AC 291 ms 720 KB
077.txt AC 73 ms 716 KB
078.txt AC 3 ms 720 KB
079.txt AC 3 ms 724 KB
080.txt AC 3 ms 720 KB
081.txt AC 3 ms 720 KB
082.txt AC 3 ms 696 KB
083.txt AC 3 ms 644 KB
084.txt AC 3 ms 716 KB
085.txt AC 3 ms 724 KB
086.txt AC 3 ms 720 KB
087.txt AC 3 ms 716 KB
088.txt AC 15 ms 720 KB
089.txt AC 297 ms 720 KB
090.txt AC 74 ms 716 KB
091.txt AC 3 ms 716 KB
092.txt AC 3 ms 720 KB
093.txt AC 3 ms 720 KB
094.txt AC 3 ms 720 KB
095.txt AC 3 ms 724 KB
096.txt AC 3 ms 720 KB
097.txt AC 3 ms 720 KB
098.txt AC 3 ms 724 KB
099.txt AC 3 ms 724 KB
100.txt AC 3 ms 720 KB
101.txt AC 15 ms 720 KB
102.txt AC 282 ms 724 KB
103.txt AC 75 ms 720 KB
104.txt AC 3 ms 724 KB
105.txt AC 3 ms 720 KB
106.txt AC 3 ms 720 KB
107.txt AC 3 ms 720 KB
108.txt AC 3 ms 716 KB
109.txt AC 3 ms 720 KB
110.txt AC 3 ms 720 KB
111.txt AC 3 ms 716 KB
112.txt AC 3 ms 720 KB
113.txt AC 3 ms 720 KB
114.txt AC 14 ms 716 KB
115.txt AC 294 ms 720 KB
116.txt AC 75 ms 720 KB
117.txt AC 3 ms 716 KB
118.txt AC 3 ms 716 KB
119.txt AC 3 ms 724 KB
120.txt AC 3 ms 716 KB
121.txt AC 3 ms 716 KB
122.txt AC 3 ms 720 KB
123.txt AC 3 ms 724 KB
124.txt AC 3 ms 716 KB
125.txt AC 3 ms 720 KB