제출 #428336

#제출 시각아이디문제언어결과실행 시간메모리
428336A_DArranging Shoes (IOI19_shoes)C++14
컴파일 에러
0 ms0 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; vector<int> vec; long long ans=0,cnt=0; vector<int> s; void fix(int x) { for(int i=0;i<s.size();i++){ if(s[i]==-x){ for(int j=i-1;j>=cnt;j--){ ans++; swap(s[j],s[j+1]); } } } cnt++; for(int i=0;i<s.size();i++){ if(s[i]==x){ for(int j=i-1;j>=cnt;j--){ ans++; swap(s[j],s[j+1]); } } } cnt++; } long long count_swaps(std::vector<int> S){ s=S; vec.clear();ans=0;cnt=0; for(int i=0;i<s.size();i++){ if(s[i]<0){ vec.push_back(abs(s[i])); } } int l=0,r=vec.size-1; while(l<=r){ if((r-l)%2){ fix(l); l++; } else{ fix(r); r--; } } return ans; }

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

shoes.cpp: In function 'void fix(int)':
shoes.cpp:9:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     for(int i=0;i<s.size();i++){
      |                 ~^~~~~~~~~
shoes.cpp:18:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |     for(int i=0;i<s.size();i++){
      |                 ~^~~~~~~~~
shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:31:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for(int i=0;i<s.size();i++){
      |                 ~^~~~~~~~~
shoes.cpp:36:19: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::size_type = long unsigned int]' (did you forget the '()' ?)
   36 |     int l=0,r=vec.size-1;
      |               ~~~~^~~~
      |                       ()