| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1365274 | weedywelon | Dark Ride (EGOI25_darkride) | C++20 | 2 ms | 480 KiB |
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <limits.h>
#include <set>
#include <string>
#include <queue>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <deque>
#include <map>
#include <chrono>
#include <random>
#include <bitset>
#include <tuple>
#define SZ(x) int(x.size())
#define FR(i,a,b) for(int i=(a);i<(b);++i)
#define FOR(i,n) FR(i,0,n)
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define A first
#define B second
#define mp(a,b) make_pair(a,b)
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef unsigned __int128 U128;
typedef __int128 I128;
typedef std::pair<int,int> PII;
typedef std::pair<LL,LL> PLL;
using namespace std;
//all on except 1: if end, 1 scream. if not, 2 scream
//only flipping rooms 0,n-1 will switch the parity of #screams
//phase 1: identify lsb at which A,B differ. k turns, where k=lsb
//phase 2: identify lowest k-1 bits using bsearch. k-1 turns
//phase 3: identify 15-k bits for both A,B. 2(15-k) turns
//tot=29 turns??
const int MAXLG=15;
signed main(){
int n; cin>>n;
//phase 1: find lsb diff
int k=-1;
for (int i=0; i<MAXLG; i++){
string s;
FOR(j,n){
if (j&(1<<i)) s+="1";
else s+="0";
}
cout<<"? "<<s<<endl;
int a; cin>>a;
if (a%2==1){
k=i;
break;
}
}
//phase 2: find first k-1 bits
int on[k];
memset(on,0,sizeof(on));
for (int i=0; i<k; i++){
string s;
FOR(j,n){
if ((j&(1<<k)) && (j&(1<<i))) s+="1";
else s+="0";
}
cout<<"? "<<s<<endl;
int a; cin>>a;
if (a%2==1) on[i]=1;
}
//phase 3: find v1, v2
int v0=0,v1=0;
FOR(i,k) if (on[i]){
v0|=(1<<i);
v1|=(1<<i);
}
v1|=(1<<k);
int MOD=(1<<(k+1));
for (int i=k+1; i<15; i++){
string s;
FOR(j,n){
if (j%MOD!=v0%MOD) s+="0";
else if (j&(1<<i)) s+="1";
else s+="0";
}
cout<<"? "<<s<<endl;
int a; cin>>a;
if (a%2==1) v0|=(1<<i);
}
for (int i=k+1; i<15; i++){
string s;
FOR(j,n){
if (j%MOD!=v1%MOD) s+="0";
else if (j&(1<<i)) s+="1";
else s+="0";
}
cout<<"? "<<s<<endl;
int a; cin>>a;
if (a%2==1) v1|=(1<<i);
}
cout<<"! "<<v0<<" "<<v1<<endl;
return 0;
}
Compilation message (stderr)
| # | 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... | ||||
