제출 #145457

#제출 시각아이디문제언어결과실행 시간메모리
145457DanerZeinArranging Shoes (IOI19_shoes)C++14
50 / 100
1083 ms3220 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; int c,i,j,id; long long count_swaps(std::vector<int> s) { c=0; for(int i=0;i<s.size();i+=2){ /* for(int j=0;j<s.size();j++){ cout<<s[j]<<" "; } cout<<endl;*/ if(s[i]>0){ int shoes=s[i],id; for(int j=i+1;j<s.size();j++){ if(s[j]==shoes*(-1)){ id=j; break; } } for(int j=id;j>i;j--){ swap(s[j],s[j-1]); c++; } } else{ if(s[i+1]!=s[i]*(-1)){ int id,shoes=s[i]*(-1); for(int j=i+1;j<s.size();j++){ if(s[j]==shoes){ id=j; break; } } for(int j=id;j>i+1;j--){ swap(s[j],s[j-1]); c++; } } } } return c; }

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

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:7:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<s.size();i+=2){
               ~^~~~~~~~~
shoes.cpp:14:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       for(int j=i+1;j<s.size();j++){
                     ~^~~~~~~~~
shoes.cpp:28:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int j=i+1;j<s.size();j++){
                ~^~~~~~~~~
shoes.cpp:27:6: warning: 'id' may be used uninitialized in this function [-Wmaybe-uninitialized]
  int id,shoes=s[i]*(-1);
      ^~
shoes.cpp:13:22: warning: 'id' may be used uninitialized in this function [-Wmaybe-uninitialized]
       int shoes=s[i],id;
                      ^~
#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...