Submission #850929

#TimeUsernameProblemLanguageResultExecution timeMemory
850929vjudge1Bubble Sort 2 (JOI18_bubblesort2)C++17
0 / 100
537 ms600 KiB
#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 (stderr)

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++) {
      |                             ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...