[KUPC2014 G] Darkroom 题解
FFTotoro
·
·
题解
又是人类智慧交互题。
考虑构造如下形式的、循环节长度为 $3D$ 的地图:
$$\begin{matrix}\underbrace{00\ldots 00}\\D\end{matrix}\begin{matrix}\underbrace{11\ldots 11}\\D\end{matrix}\begin{matrix}\underbrace{0101\ldots 0101}\\D\end{matrix}$$
因为我们可以每个人各 $3$ 个相邻位置的信息,我们就可以得出这个人正处于三种段($0$,$1$,$01$)的哪一种,又根据两人初始距离为 $D$ 就可以判断谁在左谁在右了。
放代码:
```cpp
#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false);
int n,d; string s,x; cin>>n>>d;
for(int i=0;i<n;i++)
switch(i/d%3){
case 0:s+=48; break;
case 1:s+=49; break;
default:s+=48+(i%d&1);
} // 构造地图
set<string> S;
for(int i=0;i+d+3<=n;i++)
S.emplace(s.substr(i,3)+s.substr(i+d,3));
// 用 set 预处理 i<j 对应的 6 个信息可能长什么样
array<string,3> a,b;
cout<<s<<endl,cin>>a[0]>>b[0];
cout<<"Move(A,1)"<<endl,cin>>a[1]>>x;
cout<<"Move(A,1)"<<endl,cin>>a[2]>>x;
cout<<"Move(B,1)"<<endl,cin>>x>>b[1];
cout<<"Move(B,1)"<<endl,cin>>x>>b[2];
cout<<(S.find(a[0]+a[1]+a[2]+b[0]+b[1]+b[2])!=S.end()?"i<j":"i>j")<<endl;
return 0;
}
```