Submission #63436

#TimeUsernameProblemLanguageResultExecution timeMemory
63436knon0501조화행렬 (KOI18_matrix)C++14
0 / 100
116 ms8696 KiB
#include <bits/stdc++.h> using namespace std; #define f first #define s second int n,m; const int MX=2e5+5; pair<int,pair<int,int>> a[MX]; unordered_map<long long,int> seg; unordered_map<int,int> xx; unordered_map<int,int> yy; long long nn; int ans; int p; int g(int y,int lef,int rig,int lev1,int lev2){ if(lef>=y)return 0; if(rig<y)return seg[nn*2*lev1+lev2]; int mid=(lef+rig)/2; int u=g(y,lef,mid,lev1,lev2*2); int v=g(y,mid+1,rig,lev1,lev2*2+1); return u>v ? u:v; } int f(int x,int y,int lef,int rig,int lev){ if(lef>=x)return 0; if(rig<x)return g(y,1,nn,lev,1); int mid=(lef+rig)/2; int u=f(x,y,lef,mid,lev*2); int v=f(x,y,mid+1,rig,lev*2+1); return u>v ? u:v; } void process(){ int i,j; for(nn=1 ; nn<n ; nn*=2); for(i=1 ; i<=n ; i++)cin>>a[i].f; for(i=1 ; i<=n ; i++)cin>>a[i].s.f; for(i=1 ; i<=n ; i++)cin>>a[i].s.s; sort(a+1,a+n+1); set<int> S1; set<int> S2; for(i=1 ; i<=n ; i++){ S1.insert(a[i].s.f); S2.insert(a[i].s.s); } int cnt=0; for(auto &i:S1)xx[i]=++cnt; cnt=0; for(auto &i:S2)yy[i]=++cnt; for(int ii=1 ; ii<=n ; ii++){ int k=f(xx[a[ii].s.f],yy[a[ii].s.s],1,nn,1)+1; for(i=nn+xx[a[ii].s.f]-1 ; i>=1 ; i/=2){ for(j=nn+yy[a[ii].s.s]-1 ; j>=1 ; j/=2) ans++; ///seg[nn*2*i+j]=seg[nn*2*i+j]>k ? seg[nn*2*i+j]:k; } ans=ans>k?ans:k; } cout<<ans; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>m>>n; if(m==3)process(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...