제출 #299656

#제출 시각아이디문제언어결과실행 시간메모리
299656surenArranging Shoes (IOI19_shoes)C++14
10 / 100
1 ms288 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define mk make_pair #define pb push_back #define F first #define S second int count_swaps( vector < int > vc ){ int ans = 0, i; map < int , int > mp; for( i = 0; i < vc.size(); i ++ ) mp[ vc[i] ] = 1; if( mp.size() == 2 ){ vector < int > zn, brn; for( i = vc.size()-1; i >= 0; i -- ){ if( vc[i] < 0 ) zn.pb( i ); else brn.pb( i ); } while( zn.size() > 0 && brn.size() > 0 ){ if( zn[zn.size()-1] < brn[brn.size()-1] ){ ans += brn[brn.size()-1] - zn[zn.size()-1] - 1; } else{ ans += zn[zn.size()-1] - brn[brn.size()-1]; } zn.pop_back(); brn.pop_back(); } return ans; } while( vc.size() > 0 ){ for( i = 1; i < vc.size(); i ++ ){ if( vc[i] == vc[0] * -1 ){ if( vc[i] < 0 ){ ans += i; vc.erase( vc.begin() + i ); vc.erase( vc.begin() + 0 ); break; } else{ ans += i-1; vc.erase( vc.begin() + i ); vc.erase( vc.begin() + 0 ); break; } } } } return ans; }

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

shoes.cpp: In function 'int count_swaps(std::vector<int>)':
shoes.cpp:14:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |  for( i = 0; i < vc.size(); i ++ )
      |              ~~^~~~~~~~~~~
shoes.cpp:44:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |   for( i = 1; i < vc.size(); 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...