# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
65474 |
2018-08-07T16:30:32 Z |
knon0501 |
None (KOI18_matrix) |
C++14 |
|
612 ms |
45792 KB |
#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];
map<long long,int> seg;
map<int,int> xx;
map<int,int> yy;
long long nn;
int ans;
int p;
set<int> S1;
set<int> S2;
stack<int> S;
int max2(int x,int y){
return x>y ? x:y;
}
inline int g(int y,int lev1){
S.push(1);
S.push(nn);
S.push(1);
int k=0;
while(!S.empty()){
int lv=S.top();S.pop();
int r=S.top();S.pop();
int l=S.top();S.pop();
if(l>=y)continue;
if(r<y)k=max2(k,n<=10000 ? seg[nn*2*lev1+lev1]:k);
else{
if(y>(l+r)/2+1){
k=max2(k,n<=10000 ? seg[nn*2*lev1+lev1]:k);
S.push((l+r)/2+1);
S.push(r);
S.push(lv*2+1);
}
else{
S.push(l);
S.push((l+r)/2);
S.push(lv*2);
}
}
}
return k;
}
inline int f(int x,int y){
S.push(1);
S.push(nn);
S.push(1);
int k=0;
while(!S.empty()){
int lv=S.top();S.pop();
int r=S.top();S.pop();
int l=S.top();S.pop();
if(l>=x)continue;
if(r<x)k=max2(k,g(y,lv));
else{
if(x>(l+r)/2+1){
k=max2(k,g(y,lv*2));
S.push((l+r)/2+1);
S.push(r);
S.push(lv*2+1);
}
else{
S.push(l);
S.push((l+r)/2);
S.push(lv*2);
}
}
}
return k;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>m>>n;
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);
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;
int tx,ty,k;
for(int ii=1 ; ii<=n ; ii++){
tx=xx[a[ii].s.f];
ty=yy[a[ii].s.s];
k=f(tx,ty)+1;
for(i=nn+tx-1 ; i>=1 ; i/=2){
for(j=nn+ty-1 ; j>=1 ; j/=2)
if(n<=10000){
if(seg[nn*2*i+j]<k)
seg[nn*2*i+j]=k;
else
break;
}
else
k=k;
}
ans=ans>k?ans:k;
}
cout<<ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
264 ms |
20108 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
612 ms |
45792 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
264 ms |
20108 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
612 ms |
45792 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |