Submission #143498

#TimeUsernameProblemLanguageResultExecution timeMemory
143498muradeynArranging Shoes (IOI19_shoes)C++14
0 / 100
3 ms504 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; long long count_swaps(vector<int> s) { long long ret = 0; int n = s.size(); n *= 2; for (int i = 0;i<n;i+=2) { if (s[i] != -s[i + 1]) { int fn; for (int j = i + 2;j < n;j++) { if (s[j] == -s[i + 1]) { fn = j; break; } } while (fn != i + 1) { ret++; swap(s[fn] , s[fn - 1]); fn--; } } if (s[i] > s[i + 1]) { ret++; swap(s[i] , s[i + 1]); } } return ret; }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:14:17: warning: 'fn' may be used uninitialized in this function [-Wmaybe-uninitialized]
             int fn;
                 ^~
#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...