Submission #363266

#TimeUsernameProblemLanguageResultExecution timeMemory
363266NEvOlBubble Sort 2 (JOI18_bubblesort2)C++14
0 / 100
80 ms876 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...