結果
| 問題 | No.790 ちきんの括弧並べ |
| ユーザー |
|
| 提出日時 | 2023-07-21 15:48:12 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 34 ms / 2,000 ms |
| コード長 | 393 bytes |
| コンパイル時間 | 713 ms |
| コンパイル使用メモリ | 86,764 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-21 17:40:49 |
| 合計ジャッジ時間 | 1,557 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 |
ソースコード
#include <iostream>
#include <vector>
using namespace std;
int n;
int k = 0;
int string_sum(string s) {
int ans = 0;
for (char c: s) ans += c - '0';
return ans;
}
void rec(int x, string s) {
if (x == n - 1) {
k++;
return;
}
for (int i = 0; i < x + 2 - string_sum(s); i++)
rec(x + 1, s + char(48 + i));
}
int main() {
cin >> n;
rec(0, "");
cout << k << '\n';
}