Submission #412371

#TimeUsernameProblemLanguageResultExecution timeMemory
412371nichkeBubble Sort 2 (JOI18_bubblesort2)C++14
38 / 100
9066 ms1708 KiB
#include <bits/stdc++.h> using namespace std; vector<int> countScans(vector<int> A, vector<int> X, vector<int> V) { vector<int> cnt((int)A.size()); vector<int> ans; for (int i = 0; i < A.size(); i++) { for (int j = 0; j < i; j++) { if (A[j] > A[i]) { cnt[i]++; } } } for (int i = 0; i < X.size(); i++) { int tmp = A[X[i]]; A[X[i]] = V[i]; int res = 0; for (int j = X[i] + 1; j < A.size(); j++) { if (tmp > A[j] && A[X[i]] > A[j]) continue; if (tmp <= A[j] && A[X[i]] <= A[j]) continue; if (tmp > A[j] && A[X[i]] <= A[j]) cnt[j]--; if (tmp <= A[j] && A[X[i]] > A[j]) cnt[j]++; } cnt[X[i]] = 0; for (int j = X[i] - 1; j >= 0; j--) { if (A[j] > A[X[i]]) { cnt[X[i]]++; } } for (int j = 0; j < A.size(); j++) { res = max(res, cnt[j]); } ans.push_back(res); } return ans; }

Compilation message (stderr)

bubblesort2.cpp: In function 'std::vector<int> countScans(std::vector<int>, std::vector<int>, std::vector<int>)':
bubblesort2.cpp:7:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 |  for (int i = 0; i < A.size(); i++) {
      |                  ~~^~~~~~~~~~
bubblesort2.cpp:14:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |  for (int i = 0; i < X.size(); i++) {
      |                  ~~^~~~~~~~~~
bubblesort2.cpp:18:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |   for (int j = X[i] + 1; j < A.size(); j++) {
      |                          ~~^~~~~~~~~~
bubblesort2.cpp:30:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |   for (int j = 0; 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...