結果
| 問題 | No.501 穴と文字列 |
| コンテスト | |
| ユーザー |
startcpp
|
| 提出日時 | 2016-07-10 18:35:02 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 592 bytes |
| コンパイル時間 | 774 ms |
| コンパイル使用メモリ | 55,864 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-14 16:16:20 |
| 合計ジャッジ時間 | 1,854 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 22 |
ソースコード
//1文字ずつ確定させていく
#include <iostream>
#include <string>
using namespace std;
int n, d;
int main() {
cin >> n >> d;
int rem_holl = d;
string ans;
for (int i = 1; i <= n; i++) {
if (0 <= rem_holl - 1 && rem_holl - 1 <= 2 * (n - i)) { ans += 'A'; rem_holl -= 1; continue; } //残りn-i文字で穴の個数をrem_holl - 1個にできればAを選択
if (0 <= rem_holl - 2 && rem_holl - 2 <= 2 * (n - i)) { ans += 'B'; rem_holl -= 2; continue; }
if (0 <= rem_holl && rem_holl <= 2 * (n - i)) { ans += 'C'; continue; }
}
cout << ans << endl;
return 0;
}
startcpp