Submission #813687

#TimeUsernameProblemLanguageResultExecution timeMemory
813687math_rabbit_1028Arranging Shoes (IOI19_shoes)C++14
50 / 100
1085 ms1876 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; int n; long long count_swaps(std::vector<int> s) { int ans = 0; n = s.size()/2; for (int i = 0; i < 2 * n; i += 2) { int k; for (int j = i + 1; j < 2 * n; j++) { if (-s[i] == s[j]) { k = j; break; } } for (int j = k - 1; j > i; j--) { swap(s[j + 1], s[j]); ans++; } if (s[i] > 0) { swap(s[i], s[i + 1]); ans++; } } return ans; }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:18:12: warning: 'k' may be used uninitialized in this function [-Wmaybe-uninitialized]
   18 |   for (int j = k - 1; j > i; 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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...