結果
問題 | No.470 Inverse S+T Problem |
ユーザー | ciel |
提出日時 | 2016-12-20 00:43:37 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 965 bytes |
コンパイル時間 | 1,134 ms |
コンパイル使用メモリ | 77,872 KB |
実行使用メモリ | 7,664 KB |
最終ジャッジ日時 | 2023-08-24 01:03:52 |
合計ジャッジ時間 | 5,853 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,380 KB |
testcase_01 | AC | 2 ms
4,380 KB |
testcase_02 | AC | 2 ms
4,376 KB |
testcase_03 | AC | 2 ms
4,376 KB |
testcase_04 | AC | 2 ms
4,376 KB |
testcase_05 | AC | 2 ms
4,380 KB |
testcase_06 | AC | 2 ms
4,376 KB |
testcase_07 | AC | 1 ms
4,380 KB |
testcase_08 | AC | 2 ms
4,380 KB |
testcase_09 | AC | 2 ms
4,380 KB |
testcase_10 | AC | 3 ms
4,376 KB |
testcase_11 | AC | 456 ms
4,376 KB |
testcase_12 | AC | 1 ms
4,376 KB |
testcase_13 | AC | 2 ms
4,380 KB |
testcase_14 | AC | 5 ms
4,376 KB |
testcase_15 | AC | 20 ms
4,380 KB |
testcase_16 | AC | 2 ms
4,380 KB |
testcase_17 | AC | 4 ms
4,376 KB |
testcase_18 | AC | 2 ms
4,376 KB |
testcase_19 | AC | 23 ms
4,380 KB |
testcase_20 | AC | 1 ms
4,380 KB |
testcase_21 | AC | 2 ms
4,376 KB |
testcase_22 | AC | 2 ms
4,376 KB |
testcase_23 | AC | 2 ms
4,380 KB |
testcase_24 | AC | 2 ms
4,376 KB |
testcase_25 | TLE | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
ソースコード
#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; }