# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
101343 | asifthegreat | Aliens (IOI07_aliens) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
char s[100];
char mat[500][500];
int q = 0;
int n;
bool valid(int x,int y)
{
if(x <= 0 or y <= 0 or x > n or y > n)return false;
return true;
}
bool query(int x,int y)
{
if(!valid(x,y))return false;
printf("examine %lld %lld\n",x,y);
fflush(stdout);
scanf("%s",s);
if(s[0] == 't')return true;
return false;
}
void anss(int a,int b)
{
printf("solution %lld %lld\n",a,b);
fflush(stdout);
}
int32_t main()
{
int x,y;
scamf("%lld %lld %lld",&n,&x,&y);
int temp_x = x,temp_y = y;
while(1){
if(!query(temp_x+1ll,y))break;
for(int i = 0; i <= 30;i++){
if(temp_x+(1ll<<i) > n)break;
if(query(temp_x+(1ll<<i),y)){
temp_x += (1ll<<i);
}
else break;
}
}
//cout << q << endl;
//cout << temp_x << endl;
int niche = temp_x;
temp_x = x;
while(1){
if(!query(temp_x-1,y))break;
for(int i = 0; i <= 30;i++){
if(temp_x-(1ll<<i) <= 0)break;
if(query(temp_x-(1ll<<i),y)){
temp_x -= (1ll<<i);
}
else break;
}
}
//cout << q << endl;
//cout << temp_x << endl;
int upore = temp_x;
//cout << niche << " " << upore << endl;
int expand = niche-upore+1;
//cout << expand << endl;
while(1){
if(!query(x,temp_y+1ll))break;
for(int i = 0; i <= 30;i++){
//if(x+(1ll > n)break;
if(temp_y+(1ll<<i) > n)break;
if(query(x,temp_y+(1ll<<i))){
temp_y += (1ll<<i);
}
else break;
}
}
int dan = temp_y;
int bam = temp_y-expand+1;
//{upore,niche,dan,bam roilo..}
int per_upore = upore,per_niche = niche,per_dan = dan,per_bam = bam;
//cout << q << endl;
while(1){
if(!query(upore-1,bam-1))break;
upore--,bam--;
upore = upore-expand+1;
bam = bam-expand+1;
//cout << upore << " " << bam << endl;//exit(0);
}
while(1){
if(!query(upore,bam-expand-1))break;
bam = bam-expand*2;
}
//cout << bam << endl;
while(1){
if(!query(upore-expand-1,bam))break;
upore = upore-expand*2;
}
anss(upore+(expand*2)+(expand/2),bam+(expand*2)+(expand/2));
return 0;
}