Submission #1092248

#TimeUsernameProblemLanguageResultExecution timeMemory
1092248whoknowMountains (NOI20_mountains)C++17
2 / 100
66 ms4404 KiB
#include <bits/stdc++.h> #define ll long long #define F first #define S second #define N 300005 #define ii pair<int,int> #define bit(i,j) ((i>>j)&1) #define sz(i) (int)i.size() #define endl '\n' using namespace std; int n; int a[N]; namespace sub1 { int res; int bit[N][2]; void upd(int id,int v,int k) { for(id;id<=n;id+=(id&(-id))) bit[id][k]+=v; } int get(int id,int k) { int t=0; for(id;id>0;id-=((id&(-id)))) t+=bit[id][k]; return t; } void compress() { vector<int>v; for(int i=1;i<=n;i++) v.push_back(a[i]); sort(v.begin(),v.end()); v.resize(unique(v.begin(),v.end())-v.begin()); for(int i=1;i<=n;i++) a[i]=lower_bound(v.begin(),v.end(),a[i])-v.begin()+1; } void solve() { compress(); for(int i=2;i<=n;i++) upd(a[i],1,1); upd(a[1],1,0); for(int i=2;i<n;i++) { res+=get(a[i]-1,0)*get(a[i]-1,1); upd(a[i],-1,1); upd(a[i],1,0); } cout<<res; } } main() { ios_base::sync_with_stdio(0); cin.tie(0); cin>>n; for(int i=1;i<=n;i++) cin>>a[i]; sub1::solve(); }

Compilation message (stderr)

Mountains.cpp: In function 'void sub1::upd(int, int, int)':
Mountains.cpp:19:7: warning: statement has no effect [-Wunused-value]
   19 |   for(id;id<=n;id+=(id&(-id)))
      |       ^~
Mountains.cpp: In function 'int sub1::get(int, int)':
Mountains.cpp:25:7: warning: statement has no effect [-Wunused-value]
   25 |   for(id;id>0;id-=((id&(-id))))
      |       ^~
Mountains.cpp: At global scope:
Mountains.cpp:54:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   54 | main()
      | ^~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...