제출 #282838

#제출 시각아이디문제언어결과실행 시간메모리
282838surenArranging Shoes (IOI19_shoes)C++14
컴파일 에러
0 ms0 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; int flag = true; for( i = 1; i < vc.size(); i ++ ){ if( vc[i] != vc[i-1] ){ flag = false; break; } } if( flag == true ){ for(::); vector < int > srg; vector < int > eyrg; for( i = 0; i < vc.size(); i ++ ){ if( vc[i] < 0 ) srg.pb( i ); if( vc[i] > 0 ) eyrg.pb( i ); } reverse( srg.begin(), srg.end() ); reverse( eyrg.begin(), eyrg.end() ); for( i = 0; i < vc.size(); i ++ ){ if( vc[i] == 0 ) continue; if( vc[ i ] < 0 ){ ans += eyrg[ eyrg.size() - 1 ] - i; vc[ eyrg[ eyrg.size() - 1 ] ] = 0; eyrg.pop_back(); } else{ ans += srg[ srg.size() - 1 ] - i; vc[ srg[ srg.size() - 1 ] ] = 0; srg.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:15:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |  for( i = 1; i < vc.size(); i ++ ){
      |              ~~^~~~~~~~~~~
shoes.cpp:23:9: error: expected id-expression before ')' token
   23 |   for(::);
      |         ^
shoes.cpp:24:21: error: expected initializer before ';' token
   24 |   vector < int > srg;
      |                     ^
shoes.cpp:24:21: error: could not convert 'srg' from 'std::vector<int>' to 'bool'
shoes.cpp:25:18: error: expected primary-expression before 'eyrg'
   25 |   vector < int > eyrg;
      |                  ^~~~
shoes.cpp:25:17: error: expected ')' before 'eyrg'
   25 |   vector < int > eyrg;
      |                 ^~~~~
      |                 )
shoes.cpp:23:6: note: to match this '('
   23 |   for(::);
      |      ^
shoes.cpp:25:18: error: 'eyrg' was not declared in this scope
   25 |   vector < int > eyrg;
      |                  ^~~~
shoes.cpp:27:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |   for( i = 0; i < vc.size(); i ++ ){
      |               ~~^~~~~~~~~~~
shoes.cpp:29:5: error: 'srg' was not declared in this scope
   29 |     srg.pb( i );
      |     ^~~
shoes.cpp:31:5: error: 'eyrg' was not declared in this scope
   31 |     eyrg.pb( i );
      |     ^~~~
shoes.cpp:33:12: error: 'srg' was not declared in this scope
   33 |   reverse( srg.begin(), srg.end() );
      |            ^~~
shoes.cpp:34:12: error: 'eyrg' was not declared in this scope
   34 |   reverse( eyrg.begin(), eyrg.end() );
      |            ^~~~
shoes.cpp:35:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |   for( i = 0; i < vc.size(); i ++ ){
      |               ~~^~~~~~~~~~~
shoes.cpp:54:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |   for( i = 1; i < vc.size(); i ++ ){
      |               ~~^~~~~~~~~~~