結果

問題 No.205 マージして辞書順最小
ユーザー ぷらぷら
提出日時 2024-02-24 19:57:34
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,426 bytes
コンパイル時間 1,391 ms
コンパイル使用メモリ 139,176 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-02-24 19:57:37
合計ジャッジ時間 2,716 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 1 ms
6,548 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 2 ms
6,548 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
6,548 KB
testcase_11 AC 3 ms
6,548 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 1 ms
6,548 KB
testcase_15 AC 1 ms
6,548 KB
testcase_16 AC 2 ms
6,548 KB
testcase_17 WA -
testcase_18 AC 2 ms
6,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <string.h>
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<string>S(N);
    for(int i = 0; i < N; i++) {
        cin >> S[i];
    }
    string ans = S[0];
    for(int i = 1; i < N; i++) {
        string nxt = "";
        int id = 0,id2 = 0;
        while(true) {
            if(id == ans.size()) {
                if(id2 == S[i].size()) break;
                nxt += S[i][id2];
                id2++;
                continue;
            }
            if(id2 == S[i].size()) {
                nxt += ans[id];
                id++;
                continue;
            }
            if(ans[id] < S[i][id2]) {
                nxt += ans[id];
                id++;
                continue;
            }
            nxt += S[i][id2];
            id2++;
            continue;
        }
        ans = nxt;
    }
    cout << ans << "\n";
}
0