Submission #259190

#TimeUsernameProblemLanguageResultExecution timeMemory
259190algorithm16Arranging Shoes (IOI19_shoes)C++14
30 / 100
183 ms50168 KiB
#include "shoes.h" #include<iostream> #include<map> #include<vector> using namespace std; int fwt[100005],bio[100005]; vector <int> v; void update(int x,int v) { for(x;x<100005;x+=x&-x) fwt[x]+=v; } int query(int x) { int ret=0; for(x;x>0;x-=x&-x) ret+=fwt[x]; return ret; } map <int,vector <int> > m; long long count_swaps(std::vector<int> s) { long long int ret=0; for(int i=s.size()-1;i>=0;i--) { m[s[i]].push_back(i); update(i+1,1); } for(int i=0;i<s.size();i++) { if(bio[i]) continue; int ind=m[-s[i]].back(); m[-s[i]].pop_back(); ret+=query(ind)-query(i)-1+(s[i]>0); bio[ind]=1; update(ind+1,-1); update(i+1,-1); //cout << ret << "\n"; } return ret; } /*int main() { int n; cin >> n; for(int i=0;i<n;i++) { int x; cin >> x; v.push_back(x); } cout << count_swaps(v); return 0; }*/

Compilation message (stderr)

shoes.cpp: In function 'void update(int, int)':
shoes.cpp:9:7: warning: statement has no effect [-Wunused-value]
  for(x;x<100005;x+=x&-x) fwt[x]+=v;
       ^
shoes.cpp: In function 'int query(int)':
shoes.cpp:13:7: warning: statement has no effect [-Wunused-value]
  for(x;x>0;x-=x&-x) ret+=fwt[x];
       ^
shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:23:15: 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...