Submission #1170123


Source Code Expand

// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>

using namespace std;

#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
//#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool smin(T &a, const T &b)   { return a > b ? a = b : a;    }
template<typename T> inline bool smax(T &a, const T &b)   { return a < b ? a = b : a;    }

typedef long long LL;

const int N = (int) 1e5 + 5, mod = (int) 0;
int n, done;
map<int, int> mp[N];
int ask(int x, int y) {
	if (mp[x][y]) return mp[x][y] - 1;
	++done;
	if (done >= 2 * n) {
		assert(0);
	}
	cout << "? " << x << ' ' << y << endl;
	fflush(stdout);
	char res;
	cin >> res;
	mp[x][y] = (res == 'Y') + 1;
	return res == 'Y';
}
char s[N];
int main() {
	int a, b;
	cin >> a >> b;
	if (a <= b) {
		cout << "Impossible" << endl;
		fflush(stdout);
		return 0;
	}
	vector<int> all;
	n = a + b;
	for (int j = 0; j < n; ++j) {
		if (!all.size()) {
			all.push_back(j);
		} else {
			int x = ask(all.back(), j);
			if (!x) {
				all.pop_back();
			} else {
				all.push_back(j);
			}
		}
	}
	int good = all.back();
	/*
	while (all.size() > 1) {
		vector<int> nx;
		if (all.size() == 3) {
			int x = ask(all[0], all[2]);
			int y = ask(all[1], all[2]);
			if (x + y >= 1) {
				nx.push_back(all[2]);
			} else {
				nx.push_back(all[0]);
			}
		} else {
			if ((all.size() & 1) && ((all.size() / 2) & 1)) {
				nx.push_back(all.back()); all.pop_back();
				nx.push_back(all.back()); all.pop_back();
			}
			for (int j = 0; j < (int) all.size(); j += 2) {
				int x = ask(all[j], all[j + 1]);
				if (x) nx.push_back(all[j + 1]);
			}
			if (all.size() & 1)
				nx.push_back(all.back());
		}
		all = nx;
	}
	int good = all[0];
	*/
	s[good] = '1';
	for (int j = 0; j < n; ++j)
		if (good != j) {
			s[j] = (ask(good, j) ? '1' : '0');
		}
	cout << "! ";
	string res;
	for (int j = 0; j < n; ++j) res += s[j];
	cout << res << endl;
	return 0;

}

Submission Info

Submission Time
Task F - HonestOrUnkind
User Reyna
Language C++14 (GCC 5.4.1)
Score 1300
Code Size 2657 Byte
Status AC
Exec Time 295 ms
Memory 5844 KB

Judge Result

Set Name All
Score / Max Score 1300 / 1300
Status
AC × 126
Set Name Test Cases
All 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
Case Name Status Exec Time Memory
000.txt AC 5 ms 5328 KB
001.txt AC 5 ms 5324 KB
002.txt AC 5 ms 5332 KB
003.txt AC 5 ms 5328 KB
004.txt AC 5 ms 5328 KB
005.txt AC 5 ms 5324 KB
006.txt AC 5 ms 5332 KB
007.txt AC 5 ms 5332 KB
008.txt AC 5 ms 5324 KB
009.txt AC 5 ms 5324 KB
010.txt AC 18 ms 5460 KB
011.txt AC 290 ms 5716 KB
012.txt AC 146 ms 5580 KB
013.txt AC 5 ms 5324 KB
014.txt AC 5 ms 5332 KB
015.txt AC 5 ms 5324 KB
016.txt AC 5 ms 5328 KB
017.txt AC 5 ms 5452 KB
018.txt AC 5 ms 5332 KB
019.txt AC 5 ms 5324 KB
020.txt AC 5 ms 5456 KB
021.txt AC 5 ms 5328 KB
022.txt AC 5 ms 5328 KB
023.txt AC 16 ms 5452 KB
024.txt AC 287 ms 5716 KB
025.txt AC 144 ms 5584 KB
026.txt AC 5 ms 5332 KB
027.txt AC 5 ms 5332 KB
028.txt AC 5 ms 5328 KB
029.txt AC 5 ms 5324 KB
030.txt AC 5 ms 5328 KB
031.txt AC 5 ms 5328 KB
032.txt AC 5 ms 5456 KB
033.txt AC 5 ms 5328 KB
034.txt AC 5 ms 5460 KB
035.txt AC 5 ms 5452 KB
036.txt AC 16 ms 5456 KB
037.txt AC 291 ms 5840 KB
038.txt AC 145 ms 5584 KB
039.txt AC 5 ms 5328 KB
040.txt AC 5 ms 5332 KB
041.txt AC 5 ms 5328 KB
042.txt AC 5 ms 5328 KB
043.txt AC 5 ms 5456 KB
044.txt AC 5 ms 5328 KB
045.txt AC 5 ms 5452 KB
046.txt AC 5 ms 5332 KB
047.txt AC 5 ms 5328 KB
048.txt AC 5 ms 5328 KB
049.txt AC 17 ms 5328 KB
050.txt AC 295 ms 5844 KB
051.txt AC 138 ms 5580 KB
052.txt AC 5 ms 5328 KB
053.txt AC 5 ms 5328 KB
054.txt AC 5 ms 5328 KB
055.txt AC 5 ms 5328 KB
056.txt AC 5 ms 5328 KB
057.txt AC 5 ms 5452 KB
058.txt AC 5 ms 5328 KB
059.txt AC 5 ms 5456 KB
060.txt AC 5 ms 5456 KB
061.txt AC 5 ms 5328 KB
062.txt AC 18 ms 5456 KB
063.txt AC 291 ms 5840 KB
064.txt AC 149 ms 5588 KB
065.txt AC 5 ms 5328 KB
066.txt AC 5 ms 5328 KB
067.txt AC 5 ms 5328 KB
068.txt AC 5 ms 5456 KB
069.txt AC 5 ms 5328 KB
070.txt AC 5 ms 5324 KB
071.txt AC 5 ms 5324 KB
072.txt AC 5 ms 5328 KB
073.txt AC 5 ms 5456 KB
074.txt AC 5 ms 5456 KB
075.txt AC 17 ms 5456 KB
076.txt AC 279 ms 5840 KB
077.txt AC 142 ms 5580 KB
078.txt AC 5 ms 5324 KB
079.txt AC 5 ms 5332 KB
080.txt AC 5 ms 5324 KB
081.txt AC 5 ms 5324 KB
082.txt AC 5 ms 5328 KB
083.txt AC 5 ms 5328 KB
084.txt AC 5 ms 5328 KB
085.txt AC 5 ms 5328 KB
086.txt AC 5 ms 5332 KB
087.txt AC 5 ms 5328 KB
088.txt AC 17 ms 5456 KB
089.txt AC 295 ms 5840 KB
090.txt AC 149 ms 5588 KB
091.txt AC 5 ms 5328 KB
092.txt AC 5 ms 5328 KB
093.txt AC 5 ms 5328 KB
094.txt AC 5 ms 5324 KB
095.txt AC 5 ms 5328 KB
096.txt AC 5 ms 5328 KB
097.txt AC 5 ms 5328 KB
098.txt AC 5 ms 5324 KB
099.txt AC 5 ms 5328 KB
100.txt AC 5 ms 5328 KB
101.txt AC 17 ms 5460 KB
102.txt AC 291 ms 5716 KB
103.txt AC 149 ms 5584 KB
104.txt AC 5 ms 5332 KB
105.txt AC 5 ms 5328 KB
106.txt AC 5 ms 5328 KB
107.txt AC 5 ms 5328 KB
108.txt AC 5 ms 5448 KB
109.txt AC 5 ms 5328 KB
110.txt AC 5 ms 5456 KB
111.txt AC 5 ms 5328 KB
112.txt AC 5 ms 5328 KB
113.txt AC 5 ms 5460 KB
114.txt AC 17 ms 5456 KB
115.txt AC 291 ms 5712 KB
116.txt AC 144 ms 5584 KB
117.txt AC 5 ms 5328 KB
118.txt AC 5 ms 5328 KB
119.txt AC 5 ms 5328 KB
120.txt AC 5 ms 5324 KB
121.txt AC 5 ms 5328 KB
122.txt AC 5 ms 5332 KB
123.txt AC 5 ms 5332 KB
124.txt AC 5 ms 5328 KB
125.txt AC 5 ms 5328 KB