제출 #474109

#제출 시각아이디문제언어결과실행 시간메모리
474109ValiAntonieArranging Shoes (IOI19_shoes)C++14
0 / 100
1 ms588 KiB
#include "shoes.h" #include<bits/stdc++.h> using namespace std; long long count_swaps(vector<int> v){ int indice = -1; int v2[100001]; int i = 0, nr = 0, numar = 0, j = 0, j2 = 0, nr2; int n = v.size(); for(i=0;i<n;i++) v2[i] = v[i]; for(i=0;i<n;i++){ if(v2[i] > 0 && v2[i+1] < 0){ swap(v2[i],v2[i+1]); nr2++; } } for(i=0;i<n;i++){ if(v2[i] != -v2[i+1] && v2[i+1] != -v2[i+2] && v2[i] > 0){ swap(v2[i],v2[i+1]); nr2++; } } for(i=indice;i<n;i++){ if(v[i] < 0){ indice++; numar = -v[i]; for(j=i;j>indice;j--){ swap(v[j],v[j-1]); nr++; } indice++; for(j2=1;j2<n;j2++){ if(v[j2] == numar){ for(j=i;j>indice;j--){ swap(v[j],v[j-1]); nr++; } } } i = indice; } } return min(nr,nr2); }

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

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:7:46: warning: 'nr2' may be used uninitialized in this function [-Wmaybe-uninitialized]
    7 | int i = 0, nr = 0, numar = 0, j = 0, j2 = 0, nr2;
      |                                              ^~~
#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...