Submission #826631

#TimeUsernameProblemLanguageResultExecution timeMemory
826631AlesL0Arranging Shoes (IOI19_shoes)C++17
50 / 100
1079 ms2232 KiB
#include <bits/stdc++.h> #include "shoes.h" using namespace std; typedef long long ll; ll sol = 0; void solve(ll i, vector <int> &s){ if (i < 0)return; if (s[i] > 0){ ll ind; for (int j = i-1; j >= 0; j--){ if (s[j] == -s[i]){ ind = j; break; } } for (int j = ind; j < i-1; j++){ swap(s[j], s[j+1]); sol++; } solve(i-2, s); } else { ll ind; for (int j = i-1; j >= 0; j--){ if (s[j] == -s[i]){ ind = j; break; } } for (int j = ind; j < i; j++){ swap(s[j], s[j+1]); sol++; } solve(i, s); } } long long count_swaps(std::vector<int> s) { solve(s.size()-1, s); return sol; }

Compilation message (stderr)

shoes.cpp: In function 'void solve(ll, std::vector<int>&)':
shoes.cpp:20:12: warning: 'ind' may be used uninitialized in this function [-Wmaybe-uninitialized]
   20 |   for (int j = ind; j < i-1; j++){
      |            ^
shoes.cpp:34:12: warning: 'ind' may be used uninitialized in this function [-Wmaybe-uninitialized]
   34 |   for (int j = ind; 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...