답안 #1000890

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1000890 2024-06-18T10:58:30 Z Newtonabc Aliens (IOI07_aliens) C++14
0 / 100
2 ms 344 KB
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,a,b,k=0,prev;
	int ca,cb;
	bool up,down,left,right;
	up=down=left=right=false;
	cin>>n >>a >>b;
	string inp;
	int tmpa=a,tmpb=b,da=a,db=b;
	while(true){
		string s;
		if(tmpa+(1<<k)>n){
			if(k==0) break;
			k=0,tmpa=prev;
			continue;
		}
		cout<<"examine " <<tmpa+(1<<k) <<" " <<b <<endl;
		cin>>s;
		if(s=="true") prev=tmpa+(1<<k),k++;
		else{
			if(k==0) break;
			k=0,tmpa=prev;
		}
	}
	k=0;
	while(true){
		string s;
		if(tmpb+(1<<k)>n){
			if(k==0) break;
			k=0,tmpb=prev;
			continue;
		}
		cout<<"examine " <<a <<" " <<tmpb+(1<<k) <<endl;
		cin>>s;
		if(s=="true") prev=tmpb+(1<<k),k++;
		else{
			if(k==0) break;
			k=0,tmpb=prev;
		}
	}
	/*while(true){
		string s;
		if(da-(1<<k)<0){
			if(k==0) break;
			k=0,da=prev;
			continue;
		}
		cout<<"examine " <<da-(1<<k) <<" " <<b <<endl;
		cin>>s;
		if(s=="true") prev=da-(1<<k),k++;
		else{
			if(k==0) break;
			k=0,da=prev;
		}
	}
	while(true){
		string s;
		if(db-(1<<k)<1){
			if(k==0) break;
			k=0,db=prev;
			continue;
		}
		cout<<"examine " <<a <<" " <<db-(1<<k) <<endl;
		cin>>s;
		if(s=="true") prev=db-(1<<k),k++;
		else{
			if(k==0) break;
			k=0,db=prev;
		}
	}
	int m=tmpa-da+1;
	ca=(da+tmpa)/2,cb=(db+tmpb)/2;
	while(true){
		if(ca-2*m>=1){
			cout<<"examine " <<ca-2*m <<" " <<cb <<endl;
			cin>>inp;
			if(inp=="true") left=true,inp="false";
		}
		if(ca+2*m<=n){
			cout<<"examine " <<ca+2*m <<" " <<cb <<endl;
			cin>>inp;
			if(inp=="true") right=true,inp="false";
		}
		if(cb-2*m>=1){
			cout<<"examine " <<ca <<" " <<cb-2*m <<endl;
			cin>>inp;
			if(inp=="true") down=true,inp="false";
		}
		if(cb+2*m<=n){
			cout<<"examine " <<ca <<" " <<cb+2*m <<endl;
			cin>>inp;
			if(inp=="true") up=true,inp="false";
		}
		if(up && down && right && left){
			cout<<"solution " <<ca <<" " <<cb <<endl;
			return 0;
		}
		else if(up && left && !right && !down){
			ca-=m,cb+=m;
			continue;
		}
		else if(up && right && !left && !down){
			ca+=m,cb+=m;
			continue;
		}
		else if(down && right && !left && !up){
			ca+=m,cb-=m;
			continue;
		}
		else if(left && down && !right && !up){
			ca-=m,cb-=m;
			continue;
		}
	}*/
	cout<<"solution 1 1";
}

Compilation message

aliens.cpp: In function 'int main()':
aliens.cpp:7:6: warning: unused variable 'ca' [-Wunused-variable]
    7 |  int ca,cb;
      |      ^~
aliens.cpp:7:9: warning: unused variable 'cb' [-Wunused-variable]
    7 |  int ca,cb;
      |         ^~
aliens.cpp:8:7: warning: variable 'up' set but not used [-Wunused-but-set-variable]
    8 |  bool up,down,left,right;
      |       ^~
aliens.cpp:12:20: warning: unused variable 'da' [-Wunused-variable]
   12 |  int tmpa=a,tmpb=b,da=a,db=b;
      |                    ^~
aliens.cpp:12:25: warning: unused variable 'db' [-Wunused-variable]
   12 |  int tmpa=a,tmpb=b,da=a,db=b;
      |                         ^~
aliens.cpp:31:10: warning: 'tmpb' may be used uninitialized in this function [-Wmaybe-uninitialized]
   31 |   if(tmpb+(1<<k)>n){
      |      ~~~~^~~~~~~
aliens.cpp:15:10: warning: 'tmpa' may be used uninitialized in this function [-Wmaybe-uninitialized]
   15 |   if(tmpa+(1<<k)>n){
      |      ~~~~^~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 344 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Incorrect
2 Halted 0 ms 0 KB -