Submission #224811

# Submission time Handle Problem Language Result Execution time Memory
224811 2020-04-18T22:29:27 Z Bruteforceman Bubble Sort 2 (JOI18_bubblesort2) C++11
38 / 100
5045 ms 1280 KB
#include "bits/stdc++.h"
#include "bubblesort2.h"
using namespace std;

int solve(vector <int> &A) {
    vector <int> cmp (A.size()), pos (A.size());
    for(int i = 0; i < A.size(); i++) cmp[i] = i;
    sort(cmp.begin(), cmp.end(), [&] (int i, int j) { return A[i] < A[j]; });
    for(int i = 0; i < A.size(); i++) pos[cmp[i]] = i;
    int ans = 0;
    for(int i = 0; i < A.size(); i++) {
        ans = max(ans, i - pos[i]);
    }
    return ans;
}

std::vector<int> countScans(std::vector<int> A,std::vector<int> X,std::vector<int> V){
    vector <int> answer (X.size());
    for(int i = 0; i < X.size(); i++) {
        A[X[i]] = V[i];
        answer[i] = solve(A);
    }
	return answer;
}

Compilation message

bubblesort2.cpp: In function 'int solve(std::vector<int>&)':
bubblesort2.cpp:7:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < A.size(); i++) cmp[i] = i;
                    ~~^~~~~~~~~~
bubblesort2.cpp:9:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < A.size(); i++) pos[cmp[i]] = i;
                    ~~^~~~~~~~~~
bubblesort2.cpp:11:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < A.size(); i++) {
                    ~~^~~~~~~~~~
bubblesort2.cpp: In function 'std::vector<int> countScans(std::vector<int>, std::vector<int>, std::vector<int>)':
bubblesort2.cpp:19:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < X.size(); i++) {
                    ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 20 ms 384 KB Output is correct
2 Correct 47 ms 432 KB Output is correct
3 Correct 270 ms 504 KB Output is correct
4 Correct 262 ms 504 KB Output is correct
5 Correct 249 ms 512 KB Output is correct
6 Correct 172 ms 480 KB Output is correct
7 Correct 213 ms 504 KB Output is correct
8 Correct 233 ms 504 KB Output is correct
9 Correct 248 ms 504 KB Output is correct
10 Correct 159 ms 512 KB Output is correct
11 Correct 155 ms 504 KB Output is correct
12 Correct 157 ms 384 KB Output is correct
13 Correct 156 ms 504 KB Output is correct
14 Correct 154 ms 384 KB Output is correct
15 Correct 154 ms 384 KB Output is correct
16 Correct 138 ms 384 KB Output is correct
17 Correct 138 ms 384 KB Output is correct
18 Correct 130 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 384 KB Output is correct
2 Correct 47 ms 432 KB Output is correct
3 Correct 270 ms 504 KB Output is correct
4 Correct 262 ms 504 KB Output is correct
5 Correct 249 ms 512 KB Output is correct
6 Correct 172 ms 480 KB Output is correct
7 Correct 213 ms 504 KB Output is correct
8 Correct 233 ms 504 KB Output is correct
9 Correct 248 ms 504 KB Output is correct
10 Correct 159 ms 512 KB Output is correct
11 Correct 155 ms 504 KB Output is correct
12 Correct 157 ms 384 KB Output is correct
13 Correct 156 ms 504 KB Output is correct
14 Correct 154 ms 384 KB Output is correct
15 Correct 154 ms 384 KB Output is correct
16 Correct 138 ms 384 KB Output is correct
17 Correct 138 ms 384 KB Output is correct
18 Correct 130 ms 384 KB Output is correct
19 Correct 3799 ms 780 KB Output is correct
20 Correct 5045 ms 832 KB Output is correct
21 Correct 4244 ms 836 KB Output is correct
22 Correct 4751 ms 888 KB Output is correct
23 Correct 2844 ms 808 KB Output is correct
24 Correct 2863 ms 888 KB Output is correct
25 Correct 2829 ms 800 KB Output is correct
26 Correct 2868 ms 888 KB Output is correct
27 Correct 2819 ms 796 KB Output is correct
28 Correct 2787 ms 888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 3242 ms 1280 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 20 ms 384 KB Output is correct
2 Correct 47 ms 432 KB Output is correct
3 Correct 270 ms 504 KB Output is correct
4 Correct 262 ms 504 KB Output is correct
5 Correct 249 ms 512 KB Output is correct
6 Correct 172 ms 480 KB Output is correct
7 Correct 213 ms 504 KB Output is correct
8 Correct 233 ms 504 KB Output is correct
9 Correct 248 ms 504 KB Output is correct
10 Correct 159 ms 512 KB Output is correct
11 Correct 155 ms 504 KB Output is correct
12 Correct 157 ms 384 KB Output is correct
13 Correct 156 ms 504 KB Output is correct
14 Correct 154 ms 384 KB Output is correct
15 Correct 154 ms 384 KB Output is correct
16 Correct 138 ms 384 KB Output is correct
17 Correct 138 ms 384 KB Output is correct
18 Correct 130 ms 384 KB Output is correct
19 Correct 3799 ms 780 KB Output is correct
20 Correct 5045 ms 832 KB Output is correct
21 Correct 4244 ms 836 KB Output is correct
22 Correct 4751 ms 888 KB Output is correct
23 Correct 2844 ms 808 KB Output is correct
24 Correct 2863 ms 888 KB Output is correct
25 Correct 2829 ms 800 KB Output is correct
26 Correct 2868 ms 888 KB Output is correct
27 Correct 2819 ms 796 KB Output is correct
28 Correct 2787 ms 888 KB Output is correct
29 Incorrect 3242 ms 1280 KB Output isn't correct
30 Halted 0 ms 0 KB -