結果
問題 | No.775 tatyamと素数大富豪(hard) |
ユーザー |
|
提出日時 | 2018-12-22 01:06:10 |
言語 | C++11 (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 848 bytes |
コンパイル時間 | 1,129 ms |
コンパイル使用メモリ | 81,728 KB |
実行使用メモリ | 14,800 KB |
最終ジャッジ日時 | 2024-10-14 01:28:51 |
合計ジャッジ時間 | 2,721 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 9 WA * 1 |
ソースコード
#include <iostream> #include <algorithm> #include <string> #include <vector> #include <set> #include <cstdlib> using namespace std; int n, K; string a[100]; bool cmp(string x, string y) { if (x + y != y + x) return x + y > y + x; return x.size() > y.size(); } bool cmp2(string x, string y) { return x + y > y + x; } int main() { cin >> n >> K; for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n, cmp); vector<string> ans; for (int ii = 0; ii < 50000; ii++) { string s; for (int i = 0; i < n; i++) { s += a[i]; } ans.push_back(s); next_permutation(a, a + n, cmp2); } sort(ans.rbegin(), ans.rend()); ans.erase(unique(ans.begin(), ans.end()), ans.end()); for (int i = 0; i < K; i++) { cout << ans[i] << endl; } }