Submission #152482

#TimeUsernameProblemLanguageResultExecution timeMemory
152482WLZArranging Shoes (IOI19_shoes)C++17
10 / 100
1080 ms3292 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; long long count_swaps(vector<int> s) { long long ans = 0; int n = (int) s.size(); for (int i = 0; i < n; i++) { if (i % 2 == 0) { if (s[i] < 0) { continue; } int idx; for (int j = i + 1; j < n; j++) { if (s[j] < 0) { idx = j; break; } } while (idx > i) { swap(s[idx], s[idx - 1]); idx--; ans++; } } else { if (s[i] == -s[i - 1]) { continue; } int idx; for (int j = i + 1; j < n; j++) { if (s[j] == -s[i - 1]) { idx = j; break; } } while (idx > i) { swap(s[idx], s[idx - 1]); idx--; ans++; } } } return ans; }

Compilation message (stderr)

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