제출 #520886

#제출 시각아이디문제언어결과실행 시간메모리
520886JvThunderArranging Shoes (IOI19_shoes)C++14
100 / 100
231 ms273864 KiB
#include "shoes.h" #include <bits/stdc++.h> typedef long long ll; using namespace std; queue<int> s1[2][200005]; ll ft[200005] = {0}; void upd(ll i,ll val) { for(;i<=200000;i+=i&-i) ft[i] += val; } ll query(int j) { ll ans = 0; for(;j;j-=j&-j) ans += ft[j]; return ans; } ll count_swaps(vector<int> s) { for(int i=1;i<=200000;i++) upd(i,1); ll ans = 0; for(int i=0;i<s.size();i++) { ll type = 1; if(s[i]<0) type = 0; ll tmp = abs(s[i]); if(!s1[type][tmp].empty()) { ll x = s1[type][tmp].front(); ll tans = query(i) - query(x); upd(i+1,-1); upd(x,1); s1[type][tmp].pop(); if(type==0) tans++; ans += tans; } else s1[1-type][tmp].push(i+1); } return ans; }

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

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