Submission #101342

# Submission time Handle Problem Language Result Execution time Memory
101342 2019-03-18T15:54:14 Z asifthegreat Aliens (IOI07_aliens) C++14
70 / 100
7 ms 428 KB
#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 %d %d\n",x,y);
	fflush(stdout);
	scanf("%s",s);
	if(s[0] == 't')return true;
	return false;
}

void anss(int a,int b)
{
	printf("solution %d %d\n",a,b);
	fflush(stdout);
}

int main()
{
	int x,y;
	cin >> n >> x >> y;
	int temp_x = x,temp_y = y;
	while(1){
		if(!query(temp_x+1,y))break;
		for(int i = 0; i <= 30;i++){
			if(temp_x+(1<<i) > n)break;
			if(query(temp_x+(1<<i),y)){
				temp_x += (1<<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-(1<<i) <= 0)break;
			if(query(temp_x-(1<<i),y)){
				temp_x -= (1<<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+1))break;
		for(int i = 0; i <= 30;i++){
			//if(x+(1ll > n)break;
			if(temp_y+(1<<i) > n)break;
			if(query(x,temp_y+(1<<i))){
				temp_y += (1<<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;
		
}

Compilation message

aliens.cpp: In function 'int main()':
aliens.cpp:84:6: warning: unused variable 'per_upore' [-Wunused-variable]
  int per_upore = upore,per_niche = niche,per_dan = dan,per_bam = bam;
      ^~~~~~~~~
aliens.cpp:84:24: warning: unused variable 'per_niche' [-Wunused-variable]
  int per_upore = upore,per_niche = niche,per_dan = dan,per_bam = bam;
                        ^~~~~~~~~
aliens.cpp:84:42: warning: unused variable 'per_dan' [-Wunused-variable]
  int per_upore = upore,per_niche = niche,per_dan = dan,per_bam = bam;
                                          ^~~~~~~
aliens.cpp:84:56: warning: unused variable 'per_bam' [-Wunused-variable]
  int per_upore = upore,per_niche = niche,per_dan = dan,per_bam = bam;
                                                        ^~~~~~~
aliens.cpp: In function 'bool query(int, int)':
aliens.cpp:24:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%s",s);
  ~~~~~^~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 304 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 428 KB Output is correct
2 Correct 3 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 256 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 3 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Incorrect 6 ms 384 KB too many queries
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 412 KB too many queries
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 256 KB Output is correct
2 Incorrect 7 ms 256 KB too many queries
3 Halted 0 ms 0 KB -