結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
8,756 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 21 ms
4,376 KB
testcase_07 AC 262 ms
4,376 KB
testcase_08 AC 59 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 111 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 7 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 10 ms
4,376 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 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];
unordered_set<string> se;
vector<string> 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);
	}
	string s,t;
	s.push_back(p[u][0]);
	t.push_back(p[u][1]);
	t.push_back(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.clear();
	t.clear();
	s.push_back(p[u][0]);
	s.push_back(p[u][1]);
	t.push_back(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);
	}
}
signed main(){
	int i,j;
	cin>>a;
	for(i=0;i<a;i++)
		cin>>p[i];
	saiki(0);
	cout<<"Impossible"<<endl;
}
0