제출 #599255

#제출 시각아이디문제언어결과실행 시간메모리
599255daisy2Arranging Shoes (IOI19_shoes)C++14
50 / 100
56 ms15556 KiB
#include<iostream> #include<vector> #include "shoes.h" using namespace std; vector<int> v[300005]; const int ma=100005; int fenwick[100005]; void update(int p,int v) { for(int i=p;i<=100001;i+= i & -i) { fenwick[i]+=v; } } long long sum(long long x) { long long r=0; for(int i=x;i>0;i -= i & -i) { r+=fenwick[i]; } return r; } bool used[100005]; long long count_swaps(std::vector<int> s) { for(int i=s.size()-1;i>=0;i--) { if(v[ma+s[i]].empty()) v[ma+s[i]].push_back(0); v[ma+s[i]].push_back(i); v[ma+s[i]][0]++; update(i+1,1); } int in2; long long a=0; for(int i=0;i<s.size();i++) { if(used[i]) continue; in2=v[ma-s[i]][v[ma-s[i]][0]];v[ma-s[i]][0]--; v[ma+s[i]][0]--; used[in2]=1; a+=sum(in2)-sum(i+1); update(in2+1,-1); if(s[in2]<s[i]) a++; } return a; }

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

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:36:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for(int i=0;i<s.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...