結果

問題 No.482 あなたの名は
ユーザー minamiminami
提出日時 2019-04-05 03:33:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,600 bytes
コンパイル時間 1,454 ms
コンパイル使用メモリ 167,956 KB
実行使用メモリ 5,164 KB
最終ジャッジ日時 2023-08-28 17:09:47
合計ジャッジ時間 3,313 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 39 ms
4,904 KB
testcase_16 AC 39 ms
5,164 KB
testcase_17 AC 39 ms
4,992 KB
testcase_18 AC 39 ms
4,976 KB
testcase_19 AC 39 ms
4,932 KB
testcase_20 AC 38 ms
4,916 KB
testcase_21 AC 39 ms
4,912 KB
testcase_22 AC 39 ms
4,920 KB
testcase_23 AC 39 ms
4,996 KB
testcase_24 AC 39 ms
5,008 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 16 ms
5,012 KB
testcase_28 AC 16 ms
4,980 KB
testcase_29 WA -
testcase_30 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0