結果

問題 No.3091 The Little Match Boy
ユーザー hamo21
提出日時 2025-03-09 12:33:21
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 99 ms / 2,000 ms
コード長 1,951 bytes
コンパイル時間 4,862 ms
コンパイル使用メモリ 258,980 KB
実行使用メモリ 8,608 KB
最終ジャッジ日時 2025-03-09 12:33:30
合計ジャッジ時間 9,005 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 62
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
typedef int64_t ll;
using mint=modint998244353;

typedef long double ld;
const ll MOD=1000000007;
const ll MODA=998244353;
ll vx[4]={0,1,0,-1};
ll vy[4]={1,0,-1,0};
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    a=abs(a);
    b=abs(b);
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    if(gcdmin==0)return gcdmax;
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll pow(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=pow(N,P/2,M);
        return t*t%M;
    }
    else return N*pow(N,P-1,M)%M;
}
ll pow(ll N,ll P){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=pow(N,P/2);
        return t*t;
    }
    else return N*pow(N,P-1);
}

vector<ll> fac;
vector<ll> finv;
vector<ll> inv;
void COMinit(ll N,ll P){
    rep(i,N+1){
        if(i==0){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else if(i==1){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else{
            fac.push_back(fac.at(i-1)*i%P);
            inv.push_back(P-inv.at(P%i)*(P/i)%P);
            finv.push_back(finv.at(i-1)*inv.at(i)%P);
        }
    }
}

ll COM(ll n,ll k,ll P){
    if(n<k)return 0;
    if(n<0||k<0)return 0;
    return fac.at(n)*(finv.at(k)*finv.at(n-k)%P)%P;
}

ll sc(ll x,ll row){
    if(x==1)return 1;
    if(x>=3)return 2;
    if(x==0&&row%2==0)return 1;
    if(x==2&&row%2==1)return 1;
    return 0;
}

int main(){
    ll N,M;
    cin>>N>>M;
    vector<ll> P(N);
    rep(i,N)P[i]=i;
    set<pair<ll,ll>> S;
    rep(i,M){
        ll l;
        cin>>l;
        l--;
        S.insert({min(P[l],P[l+1]),max(P[l],P[l+1])});
        swap(P[l],P[l+1]);
    }
    cout<<S.size()<<endl;
}
0