QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#195240#2387. Min Max Convertgalen_colin#WA 18ms7796kbC++141.7kb2023-10-01 02:33:542023-10-01 02:33:55

Judging History

你现在查看的是最新测评结果

  • [2023-10-01 02:33:55]
  • 评测
  • 测评结果:WA
  • 用时:18ms
  • 内存:7796kb
  • [2023-10-01 02:33:54]
  • 提交

answer

// comp = compile
// compr = compile & run
// in terminal, gocp goes to cp directory

#include <bits/stdc++.h>
using namespace std;

#include <bits/extc++.h>
using namespace __gnu_pbds;
using ll = long long;

using ordered_set = tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update>;
using pl = pair<ll, ll>;
#define f first
#define s second

ll n;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> n;

    vector<ll> a(n), b(n);
    for (ll &x: a) cin >> x;
    for (ll &x: b) cin >> x;

    ll pt = -1, last = -1;

    vector<array<ll, 3>> ops;

    for (ll i = 0; i < n; i++) {
        if (last == b[i]) {
            if (pt < i) {
                assert(pt == i - 1);
                if (last < a[i]) ops.push_back({'m', i - 1, i});
                else if (last > a[i]) ops.push_back({'M', i - 1, i});
                ++pt;
            }
            continue;
        }

        if (pt < i) {
            assert(pt == i - 1);
            last = a[i];
            ++pt;
        }
        ll pr = pt;
        while (pt < n && a[pt] != b[i]) ++pt;

        if (pt == n) {
            cout << -1 << '\n';
            return 0;
        }

        for (ll t = pt; t - 1 > pr; t--) {
            if (a[t - 1] < a[t]) ops.push_back({'M', t - 1, t});
            else if (a[t - 1] > a[t]) ops.push_back({'m', t - 1, t});
        }

        if (last < a[pt]) ops.push_back({'M', i, pt});
        else if (last > a[pt]) ops.push_back({'m', i, pt});

        last = a[pt];
    }

    assert(ops.size() <= 2 * n);

    cout << ops.size() << '\n';
    for (auto x: ops) {
        cout << ((char)x[0]) << " " << x[1] + 1 << " " << x[2] + 1 << '\n';
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 18ms
memory: 7796kb

input:

100000
80159 24037 50544 49029 20937 95595 93373 58274 55943 97218 6019 21069 7470 92698 25184 8879 68760 75476 81465 87494 92468 11304 66134 85457 88083 59682 95187 18518 63052 61310 69855 4557 82231 40498 38847 95156 2291 94195 90442 94252 27042 63660 32300 25128 47881 8924 61749 44499 7315 93110 ...

output:

99995
m 8557 8558
M 8556 8557
M 8555 8556
M 8554 8555
m 8553 8554
M 8552 8553
m 8551 8552
M 8550 8551
m 8549 8550
m 8548 8549
M 8547 8548
m 8546 8547
m 8545 8546
M 8544 8545
M 8543 8544
m 8542 8543
M 8541 8542
M 8540 8541
M 8539 8540
m 8538 8539
m 8537 8538
m 8536 8537
M 8535 8536
M 8534 8535
m 8533...

result:

wrong answer Wrong Answer!