QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#798249#9792. Ogre Sortucup-team5071#WA 0ms3848kbC++201.1kb2024-12-04 10:18:362024-12-04 10:18:37

Judging History

This is the latest submission verdict.

  • [2024-12-04 10:18:37]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3848kb
  • [2024-12-04 10:18:36]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
int n;
struct tree
{
    int c[maxn];
    int lowbit(int x) { return x & (-x); }
    void update(int x, int k)
    {
        while (x <= n)
        {
            c[x] += k;
            x += lowbit(x);
        }
    }
    int getsum(int x)
    {
        int res = 0;
        while (x > 0)
        {
            res += c[x];
            x -= lowbit(x);
        }
        return res;
    }
} tri;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    vector<int> a(n + 1), id(n + 1);
    for (int i = 1; i <= n; i++)
        cin >> a[i], id[a[i]] = i;
    int p = 1;
    for (int i = n; i >= 1; i--)
        if (a[i] != i)
        {
            p = i;
            break;
        }
    vector<pair<int, int>> ans;
    for (int i = 1; i <= n; i++)
        tri.update(i, 1);
    for (int i = p - 1; i >= 1; i--)
    {
        ans.emplace_back(tri.getsum(id[i]) + p - 1 - i, 1);
        tri.update(id[i], -1);
    }
    cout << p - 1 << " " << ans.size() << "\n";
    for (auto [x, y] : ans)
        cout << x << " " << y << "\n";
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3580kb

input:

4
1 2 4 3

output:

3 3
4 1
3 1
3 1

result:

ok Participant's output is correct

Test #2:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

5
2 4 1 3 5

output:

3 3
4 1
2 1
4 1

result:

ok Participant's output is correct

Test #3:

score: 0
Accepted
time: 0ms
memory: 3848kb

input:

3
1 2 3

output:

0 0

result:

ok Participant's output is correct

Test #4:

score: 0
Accepted
time: 0ms
memory: 3640kb

input:

4
1 2 4 3

output:

3 3
4 1
3 1
3 1

result:

ok Participant's output is correct

Test #5:

score: 0
Accepted
time: 0ms
memory: 3592kb

input:

5
2 4 1 3 5

output:

3 3
4 1
2 1
4 1

result:

ok Participant's output is correct

Test #6:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

3
1 2 3

output:

0 0

result:

ok Participant's output is correct

Test #7:

score: 0
Accepted
time: 0ms
memory: 3636kb

input:

1
1

output:

0 0

result:

ok Participant's output is correct

Test #8:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

5
5 3 4 1 2

output:

4 4
3 1
3 1
5 1
5 1

result:

ok Participant's output is correct

Test #9:

score: 0
Accepted
time: 0ms
memory: 3604kb

input:

5
4 1 2 3 5

output:

3 3
4 1
4 1
4 1

result:

ok Participant's output is correct

Test #10:

score: -100
Wrong Answer
time: 0ms
memory: 3612kb

input:

5
1 3 4 2 5

output:

3 3
2 1
4 1
3 1

result:

wrong answer Integer parameter [name=participant answer] equals to 3, violates the range [0, 2]