結果
| 問題 | No.470 Inverse S+T Problem |
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2026-06-19 11:48:25 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 878 bytes |
| 記録 | |
| コンパイル時間 | 1,210 ms |
| コンパイル使用メモリ | 191,612 KB |
| 実行使用メモリ | 9,728 KB |
| 最終ジャッジ日時 | 2026-06-19 11:48:56 |
| 合計ジャッジ時間 | 5,948 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 18 RE * 3 TLE * 1 -- * 5 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
map<string, bool> mp;
string ans[105][2];
bool fnd;
void dfs(int i, int n, string u[]) {
if (fnd) return;
if (i == n) {
fnd = true;
for (int j = 0; j < n; j++) {
cout << ans[j][0] << " " << ans[j][1] << endl;
}
return;
}
string s = u[i];
for (int j = 1; j < 3; j++) {
string a = s.substr(0, j);
string b = s.substr(j);
if (!mp[a] && !mp[b]) {
mp[a] = mp[b] = true;
ans[i][0] = a;
ans[i][1] = b;
dfs(i + 1, n, u);
mp[a] = mp[b] = false;
}
}
}
int main() {
int n;
cin >> n;
string u[105];
for (int i = 0; i < n; i++) {
cin >> u[i];
}
fnd = false;
dfs(0, n, u);
if (!fnd) {
cout << "Impossible" << endl;
}
return 0;
}
vjudge1