제출 #144707

#제출 시각아이디문제언어결과실행 시간메모리
144707chubyxdxdArranging Shoes (IOI19_shoes)C++14
10 / 100
1072 ms1916 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; long long count_swaps(std::vector<int> s) { ll tam=s.size(); if(tam/2==1){ if(s[0]<0){ return 0; } else{ return 1; } } ll hi=0; ll h,c=0,f,aux; while(hi<tam){ for(int i=hi;i<tam;i++){ if(s[i]<0){ h=i; f=s[i]; c+=abs(hi-i); break; } } for(int i=h;i>hi;i--){ aux=s[i-1]; s[i-1]=s[i]; s[i]=aux; } hi++; /*cout<<c<<" - "<<hi<<endl; for(int i=0;i<tam;i++){ cout<<s[i]<<" "; } cout<<endl;*/ for(int i=hi;i<tam;i++){ if((s[i]*-1)==f){ h=i; c+=abs(hi-i); break; } } for(int i=h;i>hi;i--){ aux=s[i-1]; s[i-1]=s[i]; s[i]=aux; } hi++; /*cout<<c<<" - "<<hi<<endl; for(int i=0;i<tam;i++){ cout<<s[i]<<" "; } cout<<endl;*/ } return c; }

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

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:38:7: warning: 'f' may be used uninitialized in this function [-Wmaybe-uninitialized]
       if((s[i]*-1)==f){
       ^~
shoes.cpp:26:13: warning: 'h' may be used uninitialized in this function [-Wmaybe-uninitialized]
     for(int i=h;i>hi;i--){
             ^
#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...