제출 #384227

#제출 시각아이디문제언어결과실행 시간메모리
384227meperdonas203Arranging Shoes (IOI19_shoes)C++17
50 / 100
516 ms147708 KiB
#include "shoes.h" #include<bits/stdc++.h> using namespace std; void mapear(vector<int> &s){ int contador=0; map<long long int,queue<long long int> > mapa; for(auto &x:s){ if(!mapa[-x].empty()){ int indice=x; x=-mapa[-x].front(); mapa[-indice].pop(); }else{ int valor=(x>0)?++contador:-1*(++contador); mapa[x].push(valor); x=valor; } } } long long int bit[100002]; long long int query(int indice){ long long int suma=0; while(indice>0){ suma+=bit[indice]; indice-=(indice&(-indice)); } return suma; } long long int query_2(int l,int r){ return(query(r)-query(l-1)); } void update(int i,int valor,int n){ while(i<=n){ bit[i]+=(long long int)valor; i+=(i&(-i)); } } long long count_swaps(vector<int> s) { long long int movs=0; mapear(s); int n=s.size()+1; for(int i=0;i<s.size();i++){ if(s[i]>0 and query_2(abs(s[i]),abs(s[i]))==0){ movs++; } movs+=query_2(abs(s[i])+1,n); update(abs(s[i]),1,n); } return movs; }

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

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