結果
問題 |
No.3091 The Little Match Boy
|
ユーザー |
|
提出日時 | 2025-04-06 16:11:07 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 92 ms / 2,000 ms |
コード長 | 564 bytes |
コンパイル時間 | 2,045 ms |
コンパイル使用メモリ | 200,396 KB |
実行使用メモリ | 10,496 KB |
最終ジャッジ日時 | 2025-04-06 16:11:13 |
合計ジャッジ時間 | 5,880 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 62 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ int N, M; cin >> N >> M; vector<int> S(M); for (int i=0; i<M; i++){ cin >> S[i]; S[i]--; } vector<int> res(N); for (int i=0; i<N; i++){ res[i] = i; } set<pair<int, int>> ans; for (int i=0; i<M; i++){ int next_s1 = res[S[i]], next_s2 = res[S[i] + 1]; res[S[i]] = next_s2, res[S[i] + 1] = next_s1; ans.insert({next_s1, next_s2}); ans.insert({next_s2, next_s1}); } cout << (int)(ans.size() / 2) << endl; }