結果

問題 No.3091 The Little Match Boy
ユーザー nonon
提出日時 2025-04-06 16:52:26
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 43 ms / 2,000 ms
コード長 391 bytes
コンパイル時間 3,361 ms
コンパイル使用メモリ 281,324 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-04-06 16:52:33
合計ジャッジ時間 5,986 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 62
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, M;
    cin >> N >> M;
    set<pair<int, int>> S;
    vector<int> P(N);
    iota(P.begin(), P.end(), 0);
    while (M--) {
        int a;
        cin >> a;
        S.insert(minmax(P[a - 1], P[a]));
        swap(P[a - 1], P[a]);
    }
    cout << S.size() << endl;
}
0