結果
問題 |
No.3091 The Little Match Boy
|
ユーザー |
![]() |
提出日時 | 2025-04-29 00:58:56 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 45 ms / 2,000 ms |
コード長 | 599 bytes |
コンパイル時間 | 3,697 ms |
コンパイル使用メモリ | 280,548 KB |
実行使用メモリ | 7,844 KB |
最終ジャッジ日時 | 2025-04-29 00:59:05 |
合計ジャッジ時間 | 8,209 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 62 |
ソースコード
#define rep(i, n) for (int i = 0; i < (int)(n); i++) #define ALL(v) v.begin(), v.end() typedef long long ll; #include <bits/stdc++.h> using namespace std; template <class T> using V=vector<T>; template <class T> using VV=V<V<T>>; int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); int n,m; cin>>n>>m; V<int> S(m); rep(i,m){ cin>>S[i]; S[i]--; } V<int> A(n); rep(i,n) A[i]=i; set<pair<int,int>> s; rep(i,m){ int a=A[S[i]],b=A[S[i]+1]; if(a>b) swap(a,b); s.insert({a,b}); swap(A[S[i]],A[S[i]+1]); } cout<<s.size()<<endl; return 0; }