제출 #243890

#제출 시각아이디문제언어결과실행 시간메모리
243890AASGArranging Shoes (IOI19_shoes)C++17
50 / 100
159 ms141308 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; int BIT[100010];int n; deque <int> de[50000]; deque <int> iz[50000]; int V[100010]; void update(int x, int val){ for(; x <= n; x += x&-x) BIT[x] += val; } int query(int x){ int sum = 0; for(; x > 0; x -= x&-x) sum += BIT[x]; return sum; } long long count_swaps(vector<int> s) { n=s.size()+1; long long r=0; for(int i=0;i<s.size();i++){ if(s[i]<0){ iz[abs(s[i])].push_back(i+1); }else{ de[s[i]].push_back(i+1); } V[i+1]=1; update(i+1,V[i+1]); } for(int i=0;i<s.size();i++){ if(s[i]<0){ int p1; p1=iz[abs(s[i])].front(); if(iz[abs(s[i])].size()>0 && p1==i+1){ int p=de[abs(s[i])].front(); r=r+abs(query(p)-query(p1)-1); V[p]--; update(p,-1); V[p1+1]++; update(p1+1,1); de[abs(s[i])].pop_front(); iz[abs(s[i])].pop_front(); } }else{ int p=de[abs(s[i])].front(); if(de[abs(s[i])].size()>0 && p==i+1){ int p1=iz[abs(s[i])].front(); r=r+abs(query(p)-query(p1)); V[p1]--; update(p1,-1); V[p]++; update(p,1); de[abs(s[i])].pop_front(); iz[abs(s[i])].pop_front(); } } } return r; }

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

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:23:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<s.size();i++){
                 ~^~~~~~~~~
shoes.cpp:32:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     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...