結果
| 問題 |
No.205 マージして辞書順最小
|
| コンテスト | |
| ユーザー |
hk0209
|
| 提出日時 | 2021-02-18 18:20:40 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 5,000 ms |
| コード長 | 904 bytes |
| コンパイル時間 | 1,787 ms |
| コンパイル使用メモリ | 170,992 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-14 23:53:52 |
| 合計ジャッジ時間 | 2,555 ms |
|
ジャッジサーバーID (参考情報) |
judge6 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 15 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPE(i,l,n) for(ll i=l;i<=ll(n);i++)
#define FORA(i,I) for(const auto& i:I)
int main(){
bool f = true;
ll n, index = -1;
string t = "";
char now = '~';
cin >> n;
vector<string> v(n);
REP(i, n){
cin >> v[i];
v[i] += "~";//番兵
}
while(f){
f = false;
now = '~';
index = -1;
REP(i, n){
if(v[i] != "~"){
f = true;
if(now > v[i][0]){
now = v[i][0];
index = i;
} else if (now == v[i][0]){
if(v[index] > v[i]) index = i;
}
}
}
if(index >= 0){
t += now;
v[index].erase(0, 1);
}
}
cout << t << endl;
}
hk0209