Submission #1040916

#TimeUsernameProblemLanguageResultExecution timeMemory
1040916idasArranging Shoes (IOI19_shoes)C++17
10 / 100
1100 ms6720 KiB
#include <bits/stdc++.h> #define FOR(i, begin, end) for(int i=(begin); i<(end); i++) #define pb push_back using namespace std; typedef long long ll; typedef vector<int> vi; const int N=2e5+10; int n, cn[N], pos[N]; vi p_pos, n_pos[N]; long long count_swaps(vector<int> s) { n=s.size(); ll ans=0; for(int i=n-1; i>=0; i--){ int src; if(i&1){ int in; for(int j=i; j>=0; j--){ if(s[j]>0){ src=s[j]; in=j; break; } } for(int j=in+1; j<=i; j++){ swap(s[j-1], s[j]); ans++; } } else{ int in; for(int j=i; j>=0; j--){ if(s[j]==-src){ in=j; break; } } for(int j=in+1; j<=i; j++){ swap(s[j-1], s[j]); ans++; } } } return ans; }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:43:21: warning: 'in' may be used uninitialized in this function [-Wmaybe-uninitialized]
   43 |             for(int j=in+1; j<=i; j++){
      |                     ^
shoes.cpp:29:21: warning: 'in' may be used uninitialized in this function [-Wmaybe-uninitialized]
   29 |             for(int j=in+1; j<=i; j++){
      |                     ^
shoes.cpp:37:26: warning: 'src' may be used uninitialized in this function [-Wmaybe-uninitialized]
   37 |                 if(s[j]==-src){
      |                          ^~~~
#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...