답안 #884046

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
884046 2023-12-06T14:58:02 Z vjudge1 Bubble Sort 2 (JOI18_bubblesort2) C++17
38 / 100
6260 ms 1180 KB
#include <bits/stdc++.h>
//#include "bubblesort2"

using namespace std;

int aint[8000 * 4 + 5];

void update(int nod, int st, int dr, int poz, int val)
{
    if(st == dr)
    {
        aint[nod] += val;
        return;
    }

    int mij = (st + dr) / 2;
    if(poz <= mij) update(nod * 2, st, mij, poz, val);
    else update(nod * 2 + 1, mij + 1, dr, poz, val);
    aint[nod] = max(aint[nod * 2], aint[nod * 2 + 1]);
}


vector<int> countScans(vector<int> a, vector<int> x, vector<int> v)
{
    int rez = 0;
    int n = a.size();
    for(int i = 0; i < n; i++)
        for(int j = i - 1; j >= 0; j--)
            if(a[j] > a[i])
                update(1, 1, n, i + 1, 1);
    int q = x.size();
    vector<int> fin;
    for(int i = 0; i < q; i++)
    {
        //cout<<rez<<" zzzz\n";
        for(int j = x[i] + 1; j < n; j++)
        {
            if(a[x[i]] > a[j])
                update(1, 1, n, j + 1, -1);
            if(v[i] > a[j])
                update(1, 1, n, j + 1, 1);
        }

        for(int j = x[i] - 1; j >= 0; j--)
        {
            if(a[j] > a[x[i]])
                update(1, 1, n, x[i] + 1, -1);
            if(a[j] > v[i])
                update(1, 1, n, x[i] + 1, 1);
        }

        a[x[i]] = v[i];
        fin.push_back(aint[1]);
    }

    return fin;
}

/*int main()
{
    int n;
    cin>>n;
    vector<int> read;
    for(int i = 1; i <= n; i++)
    {
        int a;
        cin>>a;
        read.push_back(a);
    }

    vector<int> q1, q2;
    int q;
    cin>>q;
    for(int i = 1; i <= q; i++)
    {
        int a, b;
        cin>>a>>b;
        q1.push_back(a);
        q2.push_back(b);
    }

    vector<int> rez = countScans(read, q1, q2);
    for(auto it : rez)
        cout<<it<<'\n';
    return 0;
}*/

Compilation message

bubblesort2.cpp: In function 'std::vector<int> countScans(std::vector<int>, std::vector<int>, std::vector<int>)':
bubblesort2.cpp:25:9: warning: unused variable 'rez' [-Wunused-variable]
   25 |     int rez = 0;
      |         ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 344 KB Output is correct
2 Correct 40 ms 344 KB Output is correct
3 Correct 274 ms 596 KB Output is correct
4 Correct 266 ms 600 KB Output is correct
5 Correct 140 ms 484 KB Output is correct
6 Correct 132 ms 344 KB Output is correct
7 Correct 142 ms 348 KB Output is correct
8 Correct 142 ms 488 KB Output is correct
9 Correct 143 ms 728 KB Output is correct
10 Correct 326 ms 488 KB Output is correct
11 Correct 328 ms 492 KB Output is correct
12 Correct 332 ms 492 KB Output is correct
13 Correct 294 ms 492 KB Output is correct
14 Correct 297 ms 608 KB Output is correct
15 Correct 291 ms 492 KB Output is correct
16 Correct 245 ms 492 KB Output is correct
17 Correct 244 ms 492 KB Output is correct
18 Correct 249 ms 496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 344 KB Output is correct
2 Correct 40 ms 344 KB Output is correct
3 Correct 274 ms 596 KB Output is correct
4 Correct 266 ms 600 KB Output is correct
5 Correct 140 ms 484 KB Output is correct
6 Correct 132 ms 344 KB Output is correct
7 Correct 142 ms 348 KB Output is correct
8 Correct 142 ms 488 KB Output is correct
9 Correct 143 ms 728 KB Output is correct
10 Correct 326 ms 488 KB Output is correct
11 Correct 328 ms 492 KB Output is correct
12 Correct 332 ms 492 KB Output is correct
13 Correct 294 ms 492 KB Output is correct
14 Correct 297 ms 608 KB Output is correct
15 Correct 291 ms 492 KB Output is correct
16 Correct 245 ms 492 KB Output is correct
17 Correct 244 ms 492 KB Output is correct
18 Correct 249 ms 496 KB Output is correct
19 Correct 3863 ms 672 KB Output is correct
20 Correct 5116 ms 1108 KB Output is correct
21 Correct 2637 ms 916 KB Output is correct
22 Correct 2610 ms 728 KB Output is correct
23 Correct 6254 ms 884 KB Output is correct
24 Correct 6260 ms 948 KB Output is correct
25 Correct 5560 ms 852 KB Output is correct
26 Correct 5498 ms 912 KB Output is correct
27 Correct 4778 ms 1180 KB Output is correct
28 Correct 4751 ms 868 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 151 ms 944 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 344 KB Output is correct
2 Correct 40 ms 344 KB Output is correct
3 Correct 274 ms 596 KB Output is correct
4 Correct 266 ms 600 KB Output is correct
5 Correct 140 ms 484 KB Output is correct
6 Correct 132 ms 344 KB Output is correct
7 Correct 142 ms 348 KB Output is correct
8 Correct 142 ms 488 KB Output is correct
9 Correct 143 ms 728 KB Output is correct
10 Correct 326 ms 488 KB Output is correct
11 Correct 328 ms 492 KB Output is correct
12 Correct 332 ms 492 KB Output is correct
13 Correct 294 ms 492 KB Output is correct
14 Correct 297 ms 608 KB Output is correct
15 Correct 291 ms 492 KB Output is correct
16 Correct 245 ms 492 KB Output is correct
17 Correct 244 ms 492 KB Output is correct
18 Correct 249 ms 496 KB Output is correct
19 Correct 3863 ms 672 KB Output is correct
20 Correct 5116 ms 1108 KB Output is correct
21 Correct 2637 ms 916 KB Output is correct
22 Correct 2610 ms 728 KB Output is correct
23 Correct 6254 ms 884 KB Output is correct
24 Correct 6260 ms 948 KB Output is correct
25 Correct 5560 ms 852 KB Output is correct
26 Correct 5498 ms 912 KB Output is correct
27 Correct 4778 ms 1180 KB Output is correct
28 Correct 4751 ms 868 KB Output is correct
29 Runtime error 151 ms 944 KB Execution killed with signal 11
30 Halted 0 ms 0 KB -