結果
| 問題 |
No.2671 NUPC Decompressor
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-03-13 20:52:54 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 1,190 bytes |
| コンパイル時間 | 2,226 ms |
| コンパイル使用メモリ | 209,840 KB |
| 最終ジャッジ日時 | 2025-02-20 04:13:21 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 13 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
string decommpress(string s) {
string res = "";
set<char> nupc = {'N', 'U', 'P', 'C'};
set<char> one_or_two = {'1', '2'};
for (auto&& c : s) {
if (nupc.count(c)) {
res.push_back(c);
} else if (one_or_two.count(c)) {
if (c == '2') res += res;
} else {
assert(false);
}
}
return res;
}
int main() {
int K;
cin >> K;
vector<string> compressed = {
"N1U1P1C1", // 0
"N2U1P1C1", // 1
"N1U2P1C1", // 2
"N2U2P1C1", // 3
"N1U1P2C1", // 4
"N2U1P2C1", // 5
"N1U2P2C1", // 6
"N2U2P2C1", // 7
"N1U1P1C2", // 8
"N2U1P1C2", // 9
"N1U2P1C2", // 10
"N2U2P1C2", // 11
"N1U1P2C2", // 12
"N2U1P2C2", // 13
"N1U2P2C2", // 14
"N2U2P2C2", // 15
};
vector<string> decompressed;
for (auto t : compressed) {
string t_decompressed = decommpress(t);
decompressed.push_back(t_decompressed);
}
sort(decompressed.begin(), decompressed.end());
cout << decompressed[K - 1] << endl;
}