제출 #155914

#제출 시각아이디문제언어결과실행 시간메모리
155914chubyxdxdArranging Shoes (IOI19_shoes)C++17
30 / 100
31 ms1800 KiB
#include "shoes.h" #include <bits/stdc++.h> #define all(a) a.begin(),a.end() #define allr(a) a.rbegin(),a.rend() #define F first #define S second #define INF 10000000 #define inf -10000000 #define pb push_back #define forr(i,p,n) for(int i=p;i<n;i++) #define mp make_pair #define upb(a,s) upper_bound(a.begin(),a.end(),s) #define lwb(a,s) lower_bound(a.begin(),a.end(),s) using namespace std; typedef long long ll; typedef pair<ll,ll> ii; typedef vector<ii> vii; typedef vector<ll> vi; typedef vector<vi> vvi; long long count_swaps(std::vector<int> s) { if(s.size()==2){ if(s[0]<s[1])return 0; else return 1; }else{ if(s.size()<1000){ ll c=0; for(int i=0;i<s.size();i+=2){ if(s[i]<0){ int h=s[i]*-1; int k=0; for(int j=i+1;j<s.size();j++){ if(h==s[j]){ k=j; c+=abs(i+1-j); break; } } for(int j=k;j>i+1;j--){ swap(s[j],s[j-1]); } } else{ int h=s[i]*-1; int k=0; for(int j=i+1;j<s.size();j++){ if(h==s[j]){ k=j; c+=abs(i-j); break; } } for(int j=k;j>i;j--){ swap(s[j],s[j-1]); } } /*cout<<c<<endl; for(int i=0;i<s.size();i++){ cout<<s[i]<<" "; } cout<<endl;*/ } return c; } else{ ll n=s.size(); cout<<(n*(n+1))/2<<endl; } } }

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

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:28:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<s.size();i+=2){
               ~^~~~~~~~~
shoes.cpp:32:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       for(int j=i+1;j<s.size();j++){
                     ~^~~~~~~~~
shoes.cpp:46:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       for(int j=i+1;j<s.size();j++){
                     ~^~~~~~~~~
shoes.cpp:70:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
#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...