| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1362170 | uranhishig | Dark Ride (EGOI25_darkride) | C++20 | 1 ms | 508 KiB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
int ask(string s) {
int ans;
cout << "? " << s << endl;
cin >> ans;
return ans;
}
void answer(int a, int b) {
cout << "! " << min(a, b) << " " << max(a, b) << endl;
}
void solve() {
int n;
cin >> n;
if (n <= 30) {
int ans1 = -1, ans2 = -1;
for (int i = 0; i < n; i++) {
string s(n, '1');
s[i] = '0';
int x = ask(s);
if(x == 1 and ans1 == -1) ans1 = i;
if(x == 1 and ans1 != -1) ans2 = i;
}
answer(ans1, ans2);
return;
}
string str(n, '1');
str[0] = '0';
if(ask(str) == 1) {
int l = -1;
int r = n-1;
while(l + 1 < r){
int mid=(l + r)/2;
string s(n, '0');
for (int i = 0; i <= mid; i++) s[i] = '1';
int x= ask(s);
if(x%2==0) {
r = mid;
}
else{
l = mid;
}
}
answer(0,r);
return;
}
if (n%2 == 0) {
if (n % 2 == 0) {
int l = -1;
int r = n/2 - 1;
while (l + 1 < r) {
int mid = (l + r) / 2;
string s(n, '0');
for (int i = 0; i <= mid; i++) {
s[i] = '1';
}
int x = ask(s);
if (x %2) {
r = mid;
}
else {
l = mid;
}
}
int ans1 =l;
l = n/2 - 1;
r = n - 1;
while (l+1<r) {
int mid = (l + r) / 2;
string s(n, '0');
for (int i = 0; i <= mid; i++) {
s[i] = '1';
}
int x = ask(s);
if (x % 2) {
r = mid;
}
else {
l = mid;
}
}
int ans2=l;
answer(ans1, ans2);
return;
}
}
}
signed main() {
solve();
return 0;
}| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
