結果

問題 No.470 Inverse S+T Problem
ユーザー けーけー
提出日時 2017-04-15 00:39:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,212 bytes
コンパイル時間 1,604 ms
コンパイル使用メモリ 175,860 KB
実行使用メモリ 8,756 KB
最終ジャッジ日時 2023-08-24 01:27:54
合計ジャッジ時間 6,456 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
8,756 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 22 ms
4,380 KB
testcase_07 AC 214 ms
4,376 KB
testcase_08 AC 49 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 94 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 3 ms
4,376 KB
testcase_15 AC 7 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 9 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 TLE -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define int long long
const int inf=8938103643641919514ll;
const int mod=1000000007;
const int dd[]={0,-1,0,1,0};
using namespace std;
int a,b,c,d;
char p[100000][3];
struct A{
	char c[3];
	bool operator<(const A &x)const{
		if(c[0]<x.c[0])
			return true;
		else if(c[0]>x.c[0])
			return false;
		else
			return c[1]<x.c[1];
	}
	A(){
		c[0]=0;
		c[1]=0;
		c[2]=0;
	}
};
ostream& operator<<(ostream &os,const A &x){
	return os<<x.c;
}
set<A> se;
vector<A> ve;
void saiki(int u){
	if(u==a){
		for(int i=0;i<a;i++)
			cout<<ve[i*2]<<" "<<ve[i*2+1]<<endl;;
		exit(0);
	}
	A s,t;
	s.c[0]=p[u][0];
	s.c[1]=0;
	t.c[0]=p[u][1];
	t.c[1]=p[u][2];
	if(se.find(s)==end(se)&&se.find(t)==end(se)){
		se.insert(s);
		se.insert(t);
		ve.push_back(s);
		ve.push_back(t);
		saiki(u+1);
		se.erase(s);
		se.erase(t);
		ve.resize(ve.size()-2);
	}
	s.c[0]=p[u][0];
	s.c[1]=p[u][1];
	t.c[0]=p[u][2];
	t.c[1]=0;
	if(se.find(s)==end(se)&&se.find(t)==end(se)){
		se.insert(s);
		se.insert(t);
		ve.push_back(s);
		ve.push_back(t);
		saiki(u+1);
		se.erase(s);
		se.erase(t);
		ve.resize(ve.size()-2);
	}
}
signed main(){
	int i,j;
	cin>>a;
	for(i=0;i<a;i++)
		cin>>p[i];
	saiki(0);
	cout<<"Impossible"<<endl;
}
0