結果
問題 | No.2089 置換の符号 |
ユーザー |
|
提出日時 | 2024-10-08 00:10:01 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 521 bytes |
コンパイル時間 | 3,286 ms |
コンパイル使用メモリ | 246,612 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-08 00:10:06 |
合計ジャッジ時間 | 4,787 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 33 |
ソースコード
#include <bits/stdc++.h>using namespace std;#ifdef LOCAL#include "algo/debug.hpp"#else#define debug(...) ((void)0)#endif#include <atcoder/fenwicktree>int main() {constexpr char endl = '\n';std::ios::sync_with_stdio(false);std::cin.tie(nullptr);int n; cin >> n;vector<int> a(n);for(auto&x: a) cin >> x, x--;atcoder::fenwick_tree<int> fw(n);int tt = n * (n - 1) / 2;for(int i = 0; i < n; i++) {tt -= fw.sum(0, a[i]);fw.add(a[i], 1);}cout << (tt & 1 ? -1 : 1) << endl;}