제출 #476879

#제출 시각아이디문제언어결과실행 시간메모리
476879JovanBArranging Shoes (IOI19_shoes)C++17
10 / 100
128 ms138052 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; const int N = 200000; int bit[N+5]; void bit_add(int x){ while(x <= N){ bit[x]++; x += x & -x; } } int bit_get(int x){ int res = 0; while(x){ res += bit[x]; x -= x & -x; } return res; } deque <int> ima[N+5]; long long count_swaps(std::vector<int> vec) { ll res = 0; int tr = 0; for(int i=0; i<vec.size(); i++){ int x = vec[i]; bool left = 0; if(x < 0) left = 1, x = -x; if(ima[x].size()){ int g = ima[x].front(); ima[x].pop_front(); res += bit_get(N) - bit_get(g); bit_add(g); res += left; } else{ ima[x].push_back(++tr); bit_add(tr); } } return res; }

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

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