結果
| 問題 |
No.205 マージして辞書順最小
|
| コンテスト | |
| ユーザー |
Bantako
|
| 提出日時 | 2018-06-21 20:10:32 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,216 bytes |
| コンパイル時間 | 2,002 ms |
| コンパイル使用メモリ | 181,108 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-30 17:40:10 |
| 合計ジャッジ時間 | 2,875 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 7 WA * 8 |
コンパイルメッセージ
main.cpp:15:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
15 | main(){
| ^~~~
ソースコード
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
bool comp(const string &a, const string &b){
int i;
for(i = 0;i < min(a.size(), b.size()); i++){
if(a[i] != b[i])return a[i] < b[i];
}
if(a.size() > b.size())return a[i-1] < a[i];
else return b[i-1] < b[i];
}
main(){
int N;
cin >> N;
//priority_queue<string, vector<string>, comp() > que;
priority_queue<string, vector<string>, function<bool(string, string) > >
que(
[](string a, string b){
int i;
for(i = 0;i < min(a.size(), b.size()); i++){
if(a[i] != b[i])return a[i] > b[i];
}
if(a.size() > b.size())return a[i-1] <= a[i];
else return b[i-1] <= b[i];
}
);
rep(i,0,N){
string s;
cin >> s;
que.push(s);
}
string ans;
while(!que.empty()){
auto str = que.top();
que.pop();
if(str.length() != 0){
ans.push_back(str[0]);
que.push(str.substr(1));
}
}
cout << ans << endl;
}
Bantako