結果
問題 | No.2089 置換の符号 |
ユーザー |
![]() |
提出日時 | 2022-09-30 21:58:13 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 5 ms / 2,000 ms |
コード長 | 521 bytes |
コンパイル時間 | 1,523 ms |
コンパイル使用メモリ | 168,080 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-22 23:35:27 |
合計ジャッジ時間 | 2,499 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 33 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll=long long;using ld=long double;using P=pair<ll,ll>;using V=vector<ll>;#define rep(i,n) for(ll i=0;i<n;i++)#define REP(i,n) for(ll i=1;i<=n;i++)int main(){int n;cin >> n;V a(n),b(n);rep(i,n){cin >> a[i];a[i]--;b[a[i]]=i;}int count=0;rep(i,n) if(a[i]!=i){int j=b[i];swap(a[i],a[j]);b[a[i]]=i;b[a[j]]=j;count++;}cout << 1-count%2*2 << endl;}