제출 #146070

#제출 시각아이디문제언어결과실행 시간메모리
146070DanerZeinArranging Shoes (IOI19_shoes)C++14
65 / 100
1087 ms2040 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; int c,i,j,id; long long count_swaps(std::vector<int> s) { bool sw=0; int j=s.size()/2; for(int i=0;i<s.size()/2;i++){ if(s[i]*(-1)!=s[j]){ sw=1; break; } if(s[i]>=0){sw=1; break;} if(s[j]<0){ sw=1; break; } j++; } // cout<<sw<<endl; if(sw==0){ long long acum=0; for(int i=1;i<s.size()/2;i++){ acum+=i; } return acum; } else{ 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:8:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<s.size()/2;i++){
               ~^~~~~~~~~~~
shoes.cpp:21:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=1;i<s.size()/2;i++){
                 ~^~~~~~~~~~~
shoes.cpp:28:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<s.size();i+=2){
               ~^~~~~~~~~
shoes.cpp:35:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       for(int j=i+1;j<s.size();j++){
                     ~^~~~~~~~~
shoes.cpp:49:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int j=i+1;j<s.size();j++){
                ~^~~~~~~~~
shoes.cpp:48:6: warning: 'id' may be used uninitialized in this function [-Wmaybe-uninitialized]
  int id,shoes=s[i]*(-1);
      ^~
shoes.cpp:34: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...