結果

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(void){
	int n,m;
	cin>>n>>m;
	vector<int> s(m);
	for (auto &e:s)cin>>e;
	vector<int> ord(n);
	iota(ord.begin(), ord.end(), 0);
	set<pair<int,int>> st;
	for (auto x : s){
		st.emplace(ord[x-1], ord[x]);
		st.emplace(ord[x], ord[x-1]);
		swap(ord[x-1], ord[x]);
	}
	cout<<st.size()/2<<endl;
}
0