Submission #363266

# Submission time Handle Problem Language Result Execution time Memory
363266 2021-02-05T12:02:53 Z NEvOl Bubble Sort 2 (JOI18_bubblesort2) C++14
0 / 100
80 ms 876 KB
#include "bubblesort2.h"
#include <algorithm>

using namespace std;

int get_cnt(vector<int> curr)
{
    int cnt = 0;
    int mn = curr[curr.size() - 1];
    for(int i = curr.size() - 2; -1 < i; i--)
    {
        if(mn < curr[i])
            cnt++;
        mn = min(mn, curr[i]);
    }    
    return cnt;
}

std::vector<int> countScans(std::vector<int> A,std::vector<int> X,std::vector<int> V){
	int Q=X.size();
	std::vector<int> answer(Q);
    vector<int> curr(A.size());
    for(int i = 0; i < A.size(); i++)
        curr[i] = A[i];
    int cnt = get_cnt(curr);

	for (int j=0;j<Q;j++) {
        curr[X[j]] = V[j];        
		answer[j]=get_cnt(curr);
	}
	return answer;
}

Compilation message

bubblesort2.cpp: In function 'std::vector<int> countScans(std::vector<int>, std::vector<int>, std::vector<int>)':
bubblesort2.cpp:23:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     for(int i = 0; i < A.size(); i++)
      |                    ~~^~~~~~~~~~
bubblesort2.cpp:25:9: warning: unused variable 'cnt' [-Wunused-variable]
   25 |     int cnt = get_cnt(curr);
      |         ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 80 ms 876 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -