結果
| 問題 |
No.205 マージして辞書順最小
|
| コンテスト | |
| ユーザー |
184
|
| 提出日時 | 2015-05-08 23:41:42 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 513 bytes |
| コンパイル時間 | 678 ms |
| コンパイル使用メモリ | 72,340 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-05 20:43:15 |
| 合計ジャッジ時間 | 1,424 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 1 |
| other | AC * 7 WA * 8 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:14:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
14 | int n;scanf("%d",&n);
| ~~~~~^~~~~~~~~
ソースコード
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <queue>
#include <string>
#include <functional>
#include <iostream>
using namespace std;
int main(){
int n;scanf("%d",&n);
string t,s;priority_queue<string,vector<string>, greater<string> > p;
for(int i=0;i<n;i++){cin>>s;p.push(s);}
while(p.size()){
char c=p.top()[0];
t+=c;
string tmp=p.top();tmp.erase(tmp.begin());p.pop();
if(tmp.size())p.push(tmp);
}
printf("%s\n",t.c_str());
return 0;
}
184