제출 #146007

#제출 시각아이디문제언어결과실행 시간메모리
146007gs18115Arranging Shoes (IOI19_shoes)C++14
45 / 100
229 ms75252 KiB
#include"shoes.h" #include<queue> #include<algorithm> #define eb emplace_back #define fi first #define se second #define all(x) (x).begin(),(x).end() using namespace std; typedef long long ll; typedef pair<int,int>pi; typedef pair<ll,ll>pl; const ll inf=1e18; #include<iostream> struct segtree { ll dat[800010]; void SI(int n,int s,int e,int x,int p) { dat[n]+=p; if(s==e) return; int m=s+e>>1; if(x>m) SI(n*2+1,m+1,e,x,p); else SI(n*2,s,m,x,p); return; } ll SS(int n,int s,int e,int S,int E) { if(s>E||S>e) return 0; if(S<=s&&e<=E) return dat[n]; int m=s+e>>1; return SS(n*2,s,m,S,E)+SS(n*2+1,m+1,e,S,E); } }ST; queue<int>v[100010]; long long count_swaps(vector<int>s) { ll ans=0; int n=s.size()/2; int i; for(i=0;i<n*2;i++) { ST.SI(1,0,n*2-1,i,1); if(s[i]>0) v[s[i]].push(i); } for(i=0;i<n*2;i++) { if(s[i]<0) { int t=v[-s[i]].front(); v[-s[i]].pop(); ST.SI(1,0,n*2-1,i,-1); ST.SI(1,0,n*2-1,t,-1); if(i<t) ans+=ST.SS(1,0,n*2-1,i,t); else ans+=ST.SS(1,0,n*2-1,t,i)+1; } } return ans; }

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

shoes.cpp: In member function 'void segtree::SI(int, int, int, int, int)':
shoes.cpp:22:10: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   int m=s+e>>1;
         ~^~
shoes.cpp: In member function 'll segtree::SS(int, int, int, int, int)':
shoes.cpp:35:10: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   int m=s+e>>1;
         ~^~
#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...