結果

問題 No.2597 Yet Another Topological Problem
ユーザー daiotadaiota
提出日時 2023-12-25 15:55:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,228 bytes
コンパイル時間 1,811 ms
コンパイル使用メモリ 174,692 KB
実行使用メモリ 30,788 KB
最終ジャッジ日時 2023-12-25 15:55:16
合計ジャッジ時間 13,164 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 RE -
testcase_02 AC 14 ms
19,200 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 WA -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 WA -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 14 ms
19,200 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 14 ms
19,200 KB
testcase_38 AC 14 ms
19,200 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 14 ms
19,200 KB
testcase_43 AC 14 ms
19,200 KB
testcase_44 WA -
testcase_45 AC 15 ms
19,200 KB
testcase_46 AC 14 ms
19,200 KB
testcase_47 AC 14 ms
19,328 KB
testcase_48 AC 14 ms
19,328 KB
testcase_49 AC 15 ms
19,328 KB
testcase_50 AC 14 ms
19,328 KB
testcase_51 AC 14 ms
19,328 KB
testcase_52 AC 14 ms
19,328 KB
testcase_53 AC 14 ms
19,328 KB
testcase_54 AC 14 ms
19,328 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
#define REP(i,n) for(int i=0;i<int(n);i++)

int p,q;
int vi[1000][3000];
vector<vector<P> > b(1000, vector<P>(2000));
int dx[]={1,0,0};
int dy[]={0,1,-1};

bool f=false;
void dfs(int x,int y,int c){

	if(c>250000) return;
	if(abs(y-500)>2*q) return;
	if(x>2*q) return;

	if(x==2*q && y==500){
		f=true;
		return;
	}

	vi[x][y]=1;
	vi[x+2*p][y]=1;



	REP(i,3){
		int X=x+dx[i],Y=y+dy[i];

		if(vi[X][Y]==1 || (X+2*p==2*q && Y==500)) continue;
		b[X][Y].first=x;
		b[X][Y].second=y;
		dfs(X,Y,c+1);

	}
}


vector<P> g(int x,int y){
	vector<P> path;
	path.push_back(P(x,y));
	int s=x,t=y;
	while(1){
		int v=b[s][t].first,u=b[s][t].second;
		path.push_back(P(v,u));

		if(v==0 && u==500) break;

		s=v;
		t=u;
	}

	reverse(path.begin(),path.end());

	return path;

}



int main(void){
	cin.tie(nullptr);  ios_base::sync_with_stdio(false);
	int i,j,k;


	cin >> p >> q;


	dfs(0,500,0);  // (0,0)

	if(f){
		vector<P> ans=g(2*q,500);
		int n=ans.size();
		cout <<"Possible" << endl;
		cout << n-1 << endl;
		REP(i,n) cout << ans[i].first << ' ' << ans[i].second-500 << '\n';
	}else{
		cout <<"Imossible" << endl;

	}




	return 0;
}
0