結果
| 問題 |
No.470 Inverse S+T Problem
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-12-20 00:43:37 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 965 bytes |
| コンパイル時間 | 900 ms |
| コンパイル使用メモリ | 77,360 KB |
| 実行使用メモリ | 12,068 KB |
| 最終ジャッジ日時 | 2024-12-22 13:11:04 |
| 合計ジャッジ時間 | 11,927 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 24 TLE * 3 |
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;
void dfs(const vector<string> &v,vector<int> &f,int d){
if(d==v.size()){
for(int j=0;j<d;j++){
cout<<v[j].substr(0,f[j])<<' '<<v[j].substr(f[j])<<endl;
}
exit(0);
}
for(int i=1;i<=2;i++){
int j=0;
for(;j<d;j++){
if(i==1){
if(
(v[d].substr(0,1)==(f[j]==1?v[j].substr(0,1):v[j].substr(2))) ||
(v[d].substr(1)==(f[j]==1?v[j].substr(1):v[j].substr(0,2)))
)break;
}
if(i==2){
if(
(v[d].substr(2)==(f[j]==1?v[j].substr(0,1):v[j].substr(2))) ||
(v[d].substr(0,2)==(f[j]==1?v[j].substr(1):v[j].substr(0,2)))
)break;
}
}
if(j==d){
f.push_back(i);
dfs(v,f,d+1);
f.pop_back();
}
}
}
int main(){
int N;
cin>>N;
if(N>52*52){
cout<<"Impossible"<<endl;
return 0;
}
vector<string>v(N);
for(int i=0;i<N;i++)cin>>v[i];
vector<int>f;
dfs(v,f,0);
cout<<"Impossible"<<endl;
}