답안 #850929

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
850929 2023-09-17T20:01:48 Z vjudge1 Bubble Sort 2 (JOI18_bubblesort2) C++17
0 / 100
537 ms 600 KB
#include "bubblesort2.h"
#include<bits/stdc++.h>
using namespace std;
std::vector<int> countScans(std::vector<int> A,std::vector<int> X,std::vector<int> V){
	int Q=X.size();
	//cout << Q << ' ' << A.size() << endl;
	vector<int> answer;
	int tot = 0;
	for(int i = 0; i < A.size(); i++) {
        for(int j = i-1; j >= 0; j--) {
            if(A[j] > A[i]) tot++;
        }
        for(int j = i+1; j < A.size(); j++) {
            if(A[j] < A[i]) tot++;
        }
	}
	//cout << tot << 'k' << endl;
	for(int i = 0; i < Q; i++) {
        for(int j = X[i]-1; j>= 0; j--) {
            if(A[j] > A[X[i]]) tot-= 2;
            if(A[j] > V[i]) tot+= 2;
        }
        for(int j = X[i]+1; j < A.size(); j++) {
            if(A[j] < A[X[i]]) tot-= 2;
            if(A[j] < V[i]) tot+= 2;
        }
        A[X[i]] = V[i];
      //  cout << X[i] << ' ' << V[i] << ' ' << tot/2 << 'h' << endl;
        answer.push_back(tot/2);
	}
	return answer;
}

Compilation message

bubblesort2.cpp: In function 'std::vector<int> countScans(std::vector<int>, std::vector<int>, std::vector<int>)':
bubblesort2.cpp:9:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |  for(int i = 0; i < A.size(); i++) {
      |                 ~~^~~~~~~~~~
bubblesort2.cpp:13:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |         for(int j = i+1; j < A.size(); j++) {
      |                          ~~^~~~~~~~~~
bubblesort2.cpp:23:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |         for(int j = X[i]+1; j < A.size(); j++) {
      |                             ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 537 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -