Submission #631955

# Submission time Handle Problem Language Result Execution time Memory
631955 2022-08-19T08:30:59 Z codr0 LIS (INOI20_lis) C++14
20 / 100
49 ms 596 KB
// Code by Parsa Eslami

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>

#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORR(i,a,b) for(int i=a;i>=b;i--)
#define all(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
#define pb push_back
#define maxm(a,b) a=max(a,b)
#define minm(a,b) a=min(a,b)
#define lc 2*id
#define rc 2*id+1
#define dmid int mid=(r+l)/2
#define err(x) cout<<#x<<" = "<<x<<'\n'
#define bit(i,j) ((i>>j)&1)
#define F first
#define S second

using namespace std;
using namespace __gnu_pbds;
template<typename T>
using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
const int N=2e3+4;
const int NN=2e3+4;
int arr[NN],x[NN],p[NN];
struct fenwick{
	int fen[NN];
	void upd(int k,int w){
		while(k<NN){
			maxm(fen[k],w);
			k+=(k&(-k));
		}
	}
	int get(int k){
		int rt=0;
		while(k>0){
			maxm(rt,fen[k]);
			k-=(k&(-k));
		}
		return rt;
	}
};
fenwick fen;

	int32_t main(){
	iostream::sync_with_stdio(0); cin.tie(0);

	int n; cin>>n;
	FOR(i,1,n) cin>>p[i]>>x[i];
	ordered_set<int> st0;
	FOR(i,1,n) st0.insert(i);
	FORR(i,n,1){
		p[i]=*st0.find_by_order(p[i]-1);
		st0.erase(p[i]);
		arr[p[i]]=x[i];
	}
	vector<pii> comp;
	FOR(i,1,n) comp.pb({arr[i],i});
	int z=0;
	sort(all(comp));
	FOR(i,0,SZ(comp)-1){
		if(i==0||comp[i].F!=comp[i-1].F) z++;
		arr[comp[i].S]=z;
	}
	bool ok[n+1]={};
	FOR(i,1,n){
		ok[p[i]]=1;
		int ans=0;
		FOR(j,1,n) if(ok[j]){
			int s=fen.get(arr[j]-1)+1;
			fen.upd(arr[j],s);
			maxm(ans,s);
		}
		FOR(j,1,NN-1) fen.fen[j]=0;
		cout<<ans<<'\n';
	}

	return 0;
	}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 36 ms 464 KB Output is correct
4 Correct 49 ms 468 KB Output is correct
5 Correct 33 ms 340 KB Output is correct
6 Correct 42 ms 340 KB Output is correct
7 Correct 39 ms 464 KB Output is correct
8 Correct 40 ms 472 KB Output is correct
9 Correct 40 ms 340 KB Output is correct
10 Correct 45 ms 444 KB Output is correct
11 Correct 41 ms 340 KB Output is correct
12 Correct 47 ms 468 KB Output is correct
13 Correct 45 ms 340 KB Output is correct
14 Correct 45 ms 468 KB Output is correct
15 Correct 45 ms 468 KB Output is correct
16 Correct 45 ms 340 KB Output is correct
17 Correct 44 ms 448 KB Output is correct
18 Correct 47 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 36 ms 464 KB Output is correct
4 Correct 49 ms 468 KB Output is correct
5 Correct 33 ms 340 KB Output is correct
6 Correct 42 ms 340 KB Output is correct
7 Correct 39 ms 464 KB Output is correct
8 Correct 40 ms 472 KB Output is correct
9 Correct 40 ms 340 KB Output is correct
10 Correct 45 ms 444 KB Output is correct
11 Correct 41 ms 340 KB Output is correct
12 Correct 47 ms 468 KB Output is correct
13 Correct 45 ms 340 KB Output is correct
14 Correct 45 ms 468 KB Output is correct
15 Correct 45 ms 468 KB Output is correct
16 Correct 45 ms 340 KB Output is correct
17 Correct 44 ms 448 KB Output is correct
18 Correct 47 ms 468 KB Output is correct
19 Runtime error 1 ms 596 KB Execution killed with signal 11
20 Halted 0 ms 0 KB -