結果

問題 No.411 昇順昇順ソート
コンテスト
ユーザー himueu
提出日時 2026-10-19 00:08:12
言語 C++23(gcc16)
(gcc 16.2.0 + boost 1.92.0 + ACL)
コンパイル:
g++-16 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 54 ms / 2,000 ms
+ 827µs
コード長 617 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,080 ms
コンパイル使用メモリ 175,400 KB
実行使用メモリ 9,792 KB
最終ジャッジ日時 2026-10-19 00:08:16
合計ジャッジ時間 4,216 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge6_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <algorithm>
#include <iostream>
#include <vector>

int main() {
    using namespace std;
    int n, k;
    cin >> n >> k;
    k--;
    int ans = 0;
    for (int bit = 0; bit < (1 << n); bit++) {
        int a_min = n, a_max = 0, b_min = n;
        for (int i = 0; i < n; i++) {
            if (bit >> i & 1) {
                a_min = min(a_min, i);
                a_max = max(a_max, i);
            } else {
                b_min = min(b_min, i);
            }
        }
        if (a_min == n || b_min == n) { continue; }
        if (a_min == k && a_max > b_min) { ans++; }
    }
    cout << ans << endl;
}
0