제출 #890587

#제출 시각아이디문제언어결과실행 시간메모리
890587svazArranging Shoes (IOI19_shoes)C++14
10 / 100
1097 ms4156 KiB
#include "shoes.h" #include<iostream> #include<vector> using namespace std; long long count_swaps(std::vector<int> S){ long long sw=0; vector<int> pos_der, pos_izq; for(int i=0;i<S.size()-1;i+=2){ //if(!(S[i]<0 && S[i+1]>0 && abs(S[i])==abs(S[i+1]))){ if(S[i]>0)pos_der.push_back(i); else pos_izq.push_back(i); if(S[i+1]>0)pos_der.push_back(i+1); else pos_izq.push_back(i+1); //} } for(int i=0;i<pos_izq.size();i++){ sw+=abs(pos_der[i]-pos_izq[i]); if(pos_izq[i]<pos_der[i])sw--; for(int j=i+1;j<pos_izq.size();j++){ if(pos_der[i]>pos_izq[j])pos_izq[j]++; else break; } for(int j=i+1;j<pos_der.size();j++){ if(pos_izq[i]>pos_der[j])pos_der[j]++; else break; } /* for(int i=0;i<pos_der.size();i++){ cout<<pos_der[i]<<" "; } cout<<endl; for(int i=0;i<pos_der.size();i++){ cout<<pos_izq[i]<<" "; } cout<<endl;*/ } return sw; } /*int main(){ int n,zap; cin>>n; vector<int>zapatos; for(int i=0;i<(n*2);i++){ cin>>zap; zapatos.push_back(zap); } cout<<count_swaps(zapatos)<<"\n"; return 0; }*/

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

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:8:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |     for(int i=0;i<S.size()-1;i+=2){
      |                 ~^~~~~~~~~~~
shoes.cpp:16:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     for(int i=0;i<pos_izq.size();i++){
      |                 ~^~~~~~~~~~~~~~~
shoes.cpp:19:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |         for(int j=i+1;j<pos_izq.size();j++){
      |                       ~^~~~~~~~~~~~~~~
shoes.cpp:23:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |         for(int j=i+1;j<pos_der.size();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...