Submission details
Task:Sorting books
Sender:aalto26dw_007
Submission time:2026-09-23 17:43:10 +0300
Language:C++ (C++20)
Status:READY
Result:
Test results
testverdicttime
#10.00 sdetails
#20.00 sdetails
#30.00 sdetails
#40.00 sdetails
#50.00 sdetails
#60.00 sdetails
#70.00 sdetails
#80.00 sdetails
#90.00 sdetails
#100.00 sdetails
#110.00 sdetails
#120.00 sdetails
#130.00 sdetails
#140.00 sdetails
#150.00 sdetails
#160.00 sdetails
#170.00 sdetails
#180.00 sdetails
#190.00 sdetails
#200.00 sdetails
#210.00 sdetails
#220.00 sdetails
#230.00 sdetails
#240.00 sdetails
#250.00 sdetails
#260.00 sdetails
#270.00 sdetails
#280.00 sdetails
#290.00 sdetails
#300.00 sdetails
#310.00 sdetails
#320.00 sdetails
#330.00 sdetails
#340.00 sdetails
#350.00 sdetails
#360.00 sdetails
#370.00 sdetails
#380.00 sdetails
#390.00 sdetails
#400.00 sdetails
#410.00 sdetails
#420.00 sdetails
#430.00 sdetails
#440.00 sdetails
#450.00 sdetails
#460.00 sdetails
#470.00 sdetails
#480.00 sdetails
#490.00 sdetails
#500.00 sdetails
#510.01 sdetails
#520.01 sdetails
#530.01 sdetails
#540.01 sdetails
#550.01 sdetails
#560.01 sdetails
#570.01 sdetails
#580.01 sdetails
#590.01 sdetails
#600.01 sdetails
#610.13 sdetails
#620.13 sdetails
#630.13 sdetails
#640.13 sdetails
#650.13 sdetails
#660.13 sdetails
#670.13 sdetails
#680.13 sdetails
#690.13 sdetails
#700.13 sdetails
#710.05 sdetails

Compiler report

input/code.cpp: In member function 'bool compute::start()':
input/code.cpp:37:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         for (int i=0;i<data.size();i++) {
      |                      ~^~~~~~~~~~~~
input/code.cpp:42:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |         for (int i=0;i<data.size();i++) {
      |                      ~^~~~~~~~~~~~
input/code.cpp:47:14: warning: unused variable 'sorted' [-Wunused-variable]
   47 |         bool sorted=false;
      |              ^~~~~~

Code

#include <algorithm>
#include <iostream>
#include <vector>
#include <climits>

using namespace std;
#define DEBUG std::cout<<"LINE"<<__LINE__;
#define IN(A) int A;std::cin>>A;

template<typename T> void printV(vector<T> V) {
    for (int i=0;i<V.size-1;i++) {
        cout<<V[i]<<" ";
    }
    cout<<V[V.size-1];
    cout<<endl;
}
int64_t max3(int64_t a,int64_t b,int64_t c) {
    return max(a,max(b,c));
}

struct compute {
    vector<pair<int,int>> data;
    vector<pair<int,int>> result;

    vector<int > indices;
    int counter;
    bool start() {
        IN(n);

        data.assign(n,{});
        for (int i=0;i<n;i++) {
            cin>>data[i].first;
            data[i].second=i;
        }
        indices.assign(n,0);
        result.assign(n,{0,0});
        for (int i=0;i<data.size();i++) {
            result[i]=data[i];
        }
        std::sort(result.begin(),result.end());

        for (int i=0;i<data.size();i++) {
            indices[result[i].second]=i;
        }

        counter=0;
        bool sorted=false;
        for (int i=0;i<n-1;i++) {
            if (indices[i]>i&&indices[i+1]<indices[i]) swap(i);
        }
        return true;
    }
    void swap(int x) {
        auto temp=indices[x];
        indices[x]=indices[x+1];
        indices[x+1]=temp;
        counter++;
    }
 /*   void readV(int n) {
        for (int i=0;i<n;i++) cin>>data[i];

    }*/
};

int main() {
    compute comp;
    comp.start();


}

Test details

Test 1

Verdict:

input
1
1 

correct output
0

user output
(empty)

Test 2

Verdict:

input
2
3 7 

correct output
0

user output
(empty)

Test 3

Verdict:

input
2
3 6 

correct output
0

user output
(empty)

Test 4

Verdict:

input
2
3 8 

correct output
0

user output
(empty)

Test 5

Verdict:

input
3
1 2 10 

correct output
0

user output
(empty)

Test 6

Verdict:

input
3
3 7 10 

correct output
0

user output
(empty)

Test 7

Verdict:

input
3
3 6 8 

correct output
0

user output
(empty)

Test 8

Verdict:

input
4
5 5 4 10 

correct output
2

user output
(empty)

Test 9

Verdict:

input
4
4 5 5 5 

correct output
0

user output
(empty)

Test 10

Verdict:

input
4
7 10 7 1 

correct output
4

user output
(empty)

Test 11

Verdict:

input
5
6 6 8 9 7 

correct output
2

user output
(empty)

Test 12

Verdict:

input
5
5 10 8 10 1 

correct output
5

user output
(empty)

Test 13

Verdict:

input
5
5 2 1 10 6 

correct output
4

user output
(empty)

Test 14

Verdict:

input
5
6 1 8 9 3 

correct output
4

user output
(empty)

Test 15

Verdict:

input
5
10 10 6 2 10 

correct output
5

user output
(empty)

Test 16

Verdict:

input
5
3 1 9 9 3 

correct output
3

user output
(empty)

Test 17

Verdict:

input
5
9 10 4 3 9 

correct output
6

user output
(empty)

Test 18

Verdict:

input
5
1 3 8 4 5 

correct output
2

user output
(empty)

Test 19

Verdict:

input
5
9 1 10 3 9 

correct output
4

user output
(empty)

Test 20

Verdict:

input
5
1 4 6 5 5 

correct output
2

user output
(empty)

Test 21

Verdict:

input
10
6 6 8 9 7 9 6 9 5 7 

correct output
18

user output
(empty)

Test 22

Verdict:

input
10
5 10 8 10 1 2 4 10 2 3 

correct output
25

user output
(empty)

Test 23

Verdict:

input
10
5 2 1 10 6 10 5 5 5 4 

correct output
20

user output
(empty)

Test 24

Verdict:

input
10
6 1 8 9 3 2 6 6 9 5 

correct output
18

user output
(empty)

Test 25

Verdict:

input
10
10 10 6 2 10 9 8 7 7 6 

correct output
29

user output
(empty)

Test 26

Verdict:

input
10
3 1 9 9 3 4 10 10 5 1 

correct output
17

user output
(empty)

Test 27

Verdict:

input
10
9 10 4 3 9 1 1 4 2 10 

correct output
25

user output
(empty)

Test 28

Verdict:

input
10
1 3 8 4 5 10 8 5 10 4 

correct output
12

user output
(empty)

Test 29

Verdict:

input
10
9 1 10 3 9 4 6 9 3 5 

correct output
22

user output
(empty)

Test 30

Verdict:

input
10
1 4 6 5 5 1 2 4 2 1 

correct output
25

user output
(empty)

Test 31

Verdict:

input
100
589284012 636562060 767928734 ...

correct output
2843

user output
(empty)

Test 32

Verdict:

input
100
447773962 773442532 122816 137...

correct output
2446

user output
(empty)

Test 33

Verdict:

input
100
468145963 198730372 27838076 5...

correct output
2158

user output
(empty)

Test 34

Verdict:

input
100
591414747 75940263 760367935 9...

correct output
2298

user output
(empty)

Test 35

Verdict:

input
100
967034924 587586158 185430194 ...

correct output
2580

user output
(empty)

Test 36

Verdict:

input
100
238363353 59249204 934941692 8...

correct output
2578

user output
(empty)

Test 37

Verdict:

input
100
958701283 356460601 224848374 ...

correct output
2417

user output
(empty)

Test 38

Verdict:

input
100
81935404 244103474 837431431 3...

correct output
2315

user output
(empty)

Test 39

Verdict:

input
100
937837681 11934038 257096283 9...

correct output
2692

user output
(empty)

Test 40

Verdict:

input
100
11139168 391337048 538883744 5...

correct output
2302

user output
(empty)

Test 41

Verdict:

input
200
589284012 636562060 767928734 ...

correct output
10624

user output
(empty)

Test 42

Verdict:

input
200
447773962 773442532 122816 137...

correct output
9384

user output
(empty)

Test 43

Verdict:

input
200
468145963 198730372 27838076 5...

correct output
8760

user output
(empty)

Test 44

Verdict:

input
200
591414747 75940263 760367935 9...

correct output
8939

user output
(empty)

Test 45

Verdict:

input
200
967034924 587586158 185430194 ...

correct output
9905

user output
(empty)

Test 46

Verdict:

input
200
238363353 59249204 934941692 8...

correct output
9851

user output
(empty)

Test 47

Verdict:

input
200
958701283 356460601 224848374 ...

correct output
10551

user output
(empty)

Test 48

Verdict:

input
200
81935404 244103474 837431431 3...

correct output
9163

user output
(empty)

Test 49

Verdict:

input
200
937837681 11934038 257096283 9...

correct output
9346

user output
(empty)

Test 50

Verdict:

input
200
11139168 391337048 538883744 5...

correct output
9982

user output
(empty)

Test 51

Verdict:

input
1000
589284012 636562060 767928734 ...

correct output
256701

user output
(empty)

Test 52

Verdict:

input
1000
447773962 773442532 122816 137...

correct output
243505

user output
(empty)

Test 53

Verdict:

input
1000
468145963 198730372 27838076 5...

correct output
252964

user output
(empty)

Test 54

Verdict:

input
1000
591414747 75940263 760367935 9...

correct output
246581

user output
(empty)

Test 55

Verdict:

input
1000
967034924 587586158 185430194 ...

correct output
241203

user output
(empty)

Test 56

Verdict:

input
1000
238363353 59249204 934941692 8...

correct output
251093

user output
(empty)

Test 57

Verdict:

input
1000
958701283 356460601 224848374 ...

correct output
256962

user output
(empty)

Test 58

Verdict:

input
1000
81935404 244103474 837431431 3...

correct output
250165

user output
(empty)

Test 59

Verdict:

input
1000
937837681 11934038 257096283 9...

correct output
246466

user output
(empty)

Test 60

Verdict:

input
1000
11139168 391337048 538883744 5...

correct output
249076

user output
(empty)

Test 61

Verdict:

input
200000
589284012 636562060 767928734 ...

correct output
9983154934

user output
(empty)

Test 62

Verdict:

input
200000
447773962 773442532 122816 137...

correct output
9998885834

user output
(empty)

Test 63

Verdict:

input
200000
468145963 198730372 27838076 5...

correct output
9995310844

user output
(empty)

Test 64

Verdict:

input
200000
591414747 75940263 760367935 9...

correct output
10000936270

user output
(empty)

Test 65

Verdict:

input
200000
967034924 587586158 185430194 ...

correct output
10002145347

user output
(empty)

Test 66

Verdict:

input
200000
238363353 59249204 934941692 8...

correct output
9989708150

user output
(empty)

Test 67

Verdict:

input
200000
958701283 356460601 224848374 ...

correct output
9997845631

user output
(empty)

Test 68

Verdict:

input
200000
81935404 244103474 837431431 3...

correct output
10016175198

user output
(empty)

Test 69

Verdict:

input
200000
937837681 11934038 257096283 9...

correct output
9983428867

user output
(empty)

Test 70

Verdict:

input
200000
11139168 391337048 538883744 5...

correct output
9971613818

user output
(empty)

Test 71

Verdict:

input
200000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

correct output
0

user output
(empty)