Submission #19534498


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
    ll n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    int domestic_inversion = 0;
    int foreign_inversion = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i+1; j < n; ++j) {
            if (a[i] > a[j]) {
                domestic_inversion++;
                foreign_inversion++;
            } else if (a[j] > a[i]) {
                foreign_inversion++;
            }
        }
    }
    cout << domestic_inversion << endl;
    cout << foreign_inversion << endl;
    ll d = (domestic_inversion * k) % mod;
    ll f = (((k * (k - 1) / 2) % mod) * foreign_inversion) % mod;
    cout << (d + f) % mod << endl;
}

Submission Info

Submission Time
Task B - Kleene Inversion
User tokubi_ayato
Language C++ (GCC 9.2.1)
Score 0
Code Size 827 Byte
Status WA
Exec Time 15 ms
Memory 3640 KB

Judge Result

Set Name All Sample
Score / Max Score 0 / 300 0 / 0
Status
WA × 24
WA × 3
Set Name Test Cases
All sample_01, sample_02, sample_03, testcase_0, testcase_1, testcase_10, testcase_11, testcase_12, testcase_13, testcase_14, testcase_15, testcase_16, testcase_17, testcase_18, testcase_19, testcase_2, testcase_20, testcase_3, testcase_4, testcase_5, testcase_6, testcase_7, testcase_8, testcase_9
Sample sample_01, sample_02, sample_03
Case Name Status Exec Time Memory
sample_01 WA 6 ms 3600 KB
sample_02 WA 2 ms 3552 KB
sample_03 WA 2 ms 3500 KB
testcase_0 WA 2 ms 3500 KB
testcase_1 WA 2 ms 3512 KB
testcase_10 WA 4 ms 3568 KB
testcase_11 WA 3 ms 3424 KB
testcase_12 WA 3 ms 3420 KB
testcase_13 WA 8 ms 3472 KB
testcase_14 WA 6 ms 3416 KB
testcase_15 WA 2 ms 3428 KB
testcase_16 WA 3 ms 3500 KB
testcase_17 WA 8 ms 3572 KB
testcase_18 WA 7 ms 3564 KB
testcase_19 WA 8 ms 3504 KB
testcase_2 WA 2 ms 3464 KB
testcase_20 WA 7 ms 3564 KB
testcase_3 WA 2 ms 3516 KB
testcase_4 WA 3 ms 3424 KB
testcase_5 WA 2 ms 3412 KB
testcase_6 WA 3 ms 3536 KB
testcase_7 WA 5 ms 3604 KB
testcase_8 WA 15 ms 3640 KB
testcase_9 WA 10 ms 3508 KB