Submission #1065639

#TimeUsernameProblemLanguageResultExecution timeMemory
1065639modwweArranging Shoes (IOI19_shoes)C++17
100 / 100
225 ms274116 KiB
//https://www.instagram.com/_modwwe/ #pragma GCC optimize("Ofast,unroll-loops") #include<bits/stdc++.h> //#define int long long #define ll long long #define down cout<<'\n'; #define debug cout<<" cucuucucuuu",down #define NHP ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0); #define modwwe int t;cin>>t; while(t--) #define bit(i,j) (i>>j&1) #define sobit(a) __builtin_popcountll(a) #define task "test" #define fin(x) freopen(x".inp","r",stdin) #define fou(x) freopen(x".ans","w",stdout) #define pb push_back #define checktime cerr << (double)clock() / CLOCKS_PER_SEC * 1000 << " ms"; using namespace std; void phongbeo(); const int inf=1e9; const int mod2=1e9+7; const int mod1=998244353; struct icd { long double a; int b; }; struct ib { int a; int b; }; struct ic { int a,b,c; }; struct id { int a,b,c,d; }; struct ie { int a,b,c,d,e; }; ll n,m,s1,s2,s4,s3,sf,k,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,dem=0,s33,dem3,l,r,mid; int i,s10,s12; int kk; int el=29; struct fenwick{ int bit[200001]; void upd(int x) { for(x;x<=n;x+=x&-x) bit[x]++; } int get(int x) { ll s=0; for(x;x;x-=x&-x) s+=bit[x]; return s; } }fen; long long count_swaps(vector<int> a) { n=a.size(); stack<int> s[n+1],s2[n+1]; for(int i=n-1;i>=0;--i) { if(a[i]<0) s2[-a[i]].push(i); else s[a[i]].push(i); } for(int i=0;i<n;i++) { if(a[i]<0) { if(s2[-a[i]].size()==0||s2[-a[i]].top()!=i) continue; a[i]=-a[i]; s4-=i; s3=s[a[i]].top(); s4+=s3; s4--; s4=s4-fen.get(s3)+fen.get(i); fen.upd(s3+1); s2[a[i]].pop(); s[a[i]].pop(); } else { if(s[a[i]].size()==0||s[a[i]].top()!=i) continue; s4-=i; s3=s2[a[i]].top(); s4+=s3; s4=s4-fen.get(s3)+fen.get(i); fen.upd(s3+1); s[a[i]].pop(); s2[a[i]].pop(); } } return s4; }

Compilation message (stderr)

shoes.cpp: In member function 'void fenwick::upd(int)':
shoes.cpp:54:10: warning: statement has no effect [-Wunused-value]
   54 |      for(x;x<=n;x+=x&-x)
      |          ^
shoes.cpp: In member function 'int fenwick::get(int)':
shoes.cpp:60:9: warning: statement has no effect [-Wunused-value]
   60 |     for(x;x;x-=x&-x) s+=bit[x];
      |         ^
#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...