結果

問題 No.470 Inverse S+T Problem
コンテスト
ユーザー vjudge1
提出日時 2026-06-19 11:33:00
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 852 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,091 ms
コンパイル使用メモリ 189,008 KB
実行使用メモリ 6,784 KB
最終ジャッジ日時 2026-06-19 11:33:03
合計ジャッジ時間 2,760 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 18 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
string ans[N];
set<string> sk;
int n;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    bool im = false;
    for (int i = 0; i < n; i++) {
        string u;
        cin >> u;
        bool f = false;
        for (int j = 1; j < 3; j++) {
            string s = u.substr(0, j);
            string t = u.substr(j);
            if (!sk.count(s) && !sk.count(t)) {
                sk.insert(s);
                sk.insert(t);
                ans[i] = s + " " + t;
                f = true;
                break;
            }
        }
        if (!f) {
            im = true;
        }
    }
    if (im) {
        cout << "Impossible\n";
    } else {
        for (int i = 0; i < n; i++) {
            cout << ans[i] << '\n';
        }
    }
    return 0;
}
0