結果

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

ソースコード

diff #

#ifdef LOCAL
#include <local.hpp>
#else
#pragma GCC optimize("O3")
// #pragma target("arch=skylake-avx512")
#include <bits/stdc++.h>
#define debug(...) ((void)0)
#endif

using namespace std;
using ll = long long;
using ld = long double;

void solve(int) {
    int N, M;
    cin >> N >> M;

    set<pair<int, int>> s;
    vector<int> A(N);
    iota(A.begin(), A.end(), 1);

    for (int i = 0; i < M; i++) {
        int S;
        cin >> S;
        S--;

        int x = A[S], y = A[S + 1];
        if (x > y) swap(x, y);
        s.insert({x, y});

        swap(A[S], A[S + 1]);
    }

    cout << s.size() << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    // cin >> t;
    for (int i = 1; i <= t; i++) {
        solve(i);
    }

#ifdef LOCAL
    postprocess();
#endif
}
0