結果
問題 |
No.482 あなたの名は
|
ユーザー |
![]() |
提出日時 | 2019-04-05 03:32:44 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,600 bytes |
コンパイル時間 | 1,835 ms |
コンパイル使用メモリ | 170,576 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-12-29 22:56:49 |
合計ジャッジ時間 | 3,737 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 3 |
other | WA * 28 |
ソースコード
#include "bits/stdc++.h" using namespace std; #ifdef _DEBUG #include "dump.hpp" #else #define dump(...) #endif //#define int long long #define rep(i,a,b) for(int i=(a);i<(b);i++) #define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--) #define all(c) begin(c),end(c) const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f; const int MOD = 1'000'000'007; template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; } // 転倒数(inversion number) // O(n log n) // a[i] > a[j] かつ i < j である組の数 // // Verified: // http://arc075.contest.atcoder.jp/submissions/1481787 template <class It> long long merge(It l, It m, It r) { long long cnt = 0; vector<int> tmp(r - l); It it = tmp.begin(), it1 = l, it2 = m; while (it1 != m && it2 != r) { if (*it1 < *it2) *it++ = *it1++; else *it++ = *it2++, cnt += m - it1; } while (it1 != m) *it++ = *it1++; while (it2 != r) *it++ = *it2++; move(tmp.begin(), tmp.end(), l); return cnt; }; template <class It> long long mergeSort(It l, It r) { if (r - l <= 1)return 0; long long cnt = 0; It m = l + (r - l) / 2; cnt += mergeSort(l, m); cnt += mergeSort(m, r); cnt += merge(l, m, r); return cnt; } signed main() { cin.tie(0); ios::sync_with_stdio(false); int N, K; cin >> N >> K; vector<int> D(N); rep(i, 0, N) { cin >> D[i]; } long long inv = mergeSort(all(D)); if(K % 2 == inv % 2) cout << "Yes" << endl; else cout << "No" << endl; return 0; }