제출 #1364242

#제출 시각아이디문제언어결과실행 시간메모리
1364242jellybeanFind the Box (EGOI23_findthebox)C++20
63 / 100
0 ms412 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define fi first
#define se second
#define dd(x) cout<<#x<<" is "<<x<<endl;
#define dd2(x,y) cout<<#x<<" is "<<x<<" "<<#y<<" is "<<y<<endl;
typedef pair<int,int> pii;

signed main(){
	//ios::sync_with_stdio(0); cin.tie(0);
	
	int h,w,r,c; cin>>h>>w;
	
	cout<<"? ";
	for(int i=0; i<w; i++) cout<<">";
	cout<<endl;
	cin>>r>>c;
	if(c != w-1){
		cout<<"! 0 "<<c+1<<endl;
		return 0;
	}
	
	cout<<"? ";
	for(int i=0; i<h; i++) cout<<"v";
	cout<<endl;
	cin>>r>>c;
	if(r != h-1){
		cout<<"! "<<r+1<<" 0"<<endl;
		return 0;
	}
	
	int n = max(h,w);
	int row=-1, col=-1;
	
	cout<<"? ";
	for(int i=1; i<n; i++){
		if(i%2){
			cout<<"v";
			for(int j=0; j<i; j++) cout<<">";
			for(int j=0; j<i; j++) cout<<"^";
		} else {
			cout<<">";
			for(int j=0; j<i; j++) cout<<"v";
			for(int j=0; j<i; j++) cout<<"<";
		}
	}
	cout<<endl;
	
	cin>>r>>c;
	if(n%2){
		if(r != h-1) row = r+1;
	} else {
		if(c != w-1) col = c+1;
	}
	
	cout<<"? ";
	for(int i=1; i<n; i++){
		if(i%2){
			cout<<">";
			for(int j=0; j<i; j++) cout<<"v";
			for(int j=0; j<i; j++) cout<<"<";
		} else {
			cout<<"v";
			for(int j=0; j<i; j++) cout<<">";
			for(int j=0; j<i; j++) cout<<"^";
		}
	}
	cout<<endl;
	
	cin>>r>>c;
	if(n%2){
		if(c != w-1) col = c+1;
	} else {
		if(r != h-1) row = r+1;
	}
	
	if(row != -1 and col != -1){
		cout<<"! "<<row<<" "<<col<<endl;
		return 0;
	}
	
	cout<<"? ";
	if(row != -1){
		for(int i=0; i<row; i++) cout<<"v";
		for(int i=0; i<w-1; i++) cout<<">";
		cout<<endl;
		cin>>r>>c;
		cout<<"! "<<row<<" "<<c+1<<endl;
	} else {
		for(int i=0; i<col; i++) cout<<">";
		for(int i=0; i<h-1; i++) cout<<"v";
		cout<<endl;
		cin>>r>>c;
		cout<<"! "<<r+1<<" "<<col<<endl;
	}
	
	return 0;
}
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…