제출 #573070

#제출 시각아이디문제언어결과실행 시간메모리
573070sff_userArranging Shoes (IOI19_shoes)C++17
0 / 100
1 ms212 KiB
#include "shoes.h" #include <bits/stdc++.h> #define vi vector<int> #define ll long long using namespace std; ll count_swaps(vector<int> s){ int n = s.size() / 2; ll ans = 0; int pref[2*n]; int encZ=0; int l,r; for(int i = 0 ; i < 2*n ; i++){ if(s[i]<0){ l=i; break; } } for(int i = 0 ;i < 2*n ; i++){ if(s[i]>0){ r=i; break; } } for(int i = 0 ; i < 2*n ; i++){ if(s[i]==0){ encZ++; pref[i]=encZ; continue; } if(s[i] < 0){ ans += r-l-1-(pref[r]-pref[max(l-1,0)]); s[r]=0; for(int j = l+1 ; j < 2*n ; j++){ if(s[j] <0){ l=j; break; } } for(int j = r ; j < 2*n ; j++){ if(s[j]>0){ r=j; break; } } } else{ ans += l-r-(pref[l]-pref[max(r-1,0)]); s[l] = 0; for(int j = r+1 ; j < 2*n ; j++){ if(s[j] >0){ r=j; break; } } for(int j = l+1 ; j < 2*n ; j++){ if(s[j]<0){ l=j; break; } } } } return ans; } // int main(){ // int p=1,n=-1; // cout << count_swaps({p,n,n,n,n,p,p,n,p,p,p,n,n,p}) << endl; // }

컴파일 시 표준 에러 (stderr) 메시지

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:36:12: warning: 'l' may be used uninitialized in this function [-Wmaybe-uninitialized]
   36 |    for(int j = l+1 ; j < 2*n ; 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...