제출 #395331

#제출 시각아이디문제언어결과실행 시간메모리
395331ja_kingyArranging Shoes (IOI19_shoes)C++14
50 / 100
60 ms12688 KiB
#include "shoes.h" using namespace std; const int mxN = 1e5+10; vector<int> of_type[2*mxN]; int bit[mxN]; void upd(int x) {for (x++; x<mxN; x+=x&-x) bit[x]++;} int qry(int x) { int res = 0; for (x++; x; x-=x&-x) res += bit[x]; return res; } long long count_swaps(std::vector<int> s) { long long ans = 0; for (int i = s.size(); i--;) { of_type[s[i]+mxN].push_back(i); } for (int i = 0; i < s.size(); ++i) { if (i == of_type[s[i]+mxN].back()) { int x = of_type[mxN-s[i]].back(); ans += x - i + (s[i] > 0) - qry(x) + qry(i) - 1; upd(x); of_type[s[i]+mxN].pop_back(); of_type[mxN-s[i]].pop_back(); } } return ans; }

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

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:21:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |  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...