제출 #428094

#제출 시각아이디문제언어결과실행 시간메모리
428094A_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]); } } } ans++; return ans; } 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])); } } for(auto x:vec){ fix(x); } return ans; if(s.size()==2)return s[0]>s[1]; long long n=s.size(); n/=2; return n*(n-1)/2; }

컴파일 시 표준 에러 (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:27:12: error: return-statement with a value, in function returning 'void' [-fpermissive]
   27 |     return ans;
      |            ^~~
shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:32:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     for(int i=0;i<s.size();i++){
      |                 ~^~~~~~~~~