답안 #109751

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
109751 2019-05-07T23:04:51 Z aer0park 조화행렬 (KOI18_matrix) C++14
29 / 100
323 ms 22992 KB
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
struct el{
    el(ll _x,ll _y,ll _z):x(_x),y(_y),z(_z) { }
    ll x,y,z;
};
 
bool cmp(el a,el b)
{
   	return a.x<b.x;
}
ll m,n,ar[4][200005],pw[3][200014],anw;
vector<ll> arr[4];
vector<el> q;
 
ll val(ll a,ll b)
{
	ll ret=0;
	while(a)
	{
		ret=max(pw[b][a],ret);
		a-=(a&-a);
	}
	return ret;
}
 
void upd(ll a,ll b,ll x)
{
	while(a<=n)
	{
		pw[b][a]=max(x,pw[b][a]);
		a+=(a&-a);
	}
}
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>m>>n;
    for(int j=0;j<m;j++)
        for(int i=1;i<=n;i++)
        {
            cin>>ar[j+1][i];
            arr[j].push_back(ar[j+1][i]);
        }
    if(m==2)
        for(int i=0;i<n;i++)
        {
        	arr[2].push_back(arr[1][i]);
        	ar[3][i+1]=arr[1][i];
		}
    for(int j=0;j<3;j++)
        sort(arr[j].begin(),arr[j].end());
    for(int j=0;j<3;j++)
        for(int i=0;i<n;i++)
            ar[j+1][i+1]=lower_bound(arr[j].begin(),arr[j].end(),ar[j+1][i+1])-arr[j].begin()+1;
    for(int i=1;i<=n;i++)
        q.push_back(el(ar[1][i],ar[2][i],ar[3][i]));
    sort(q.begin(),q.end(),cmp);
	for(int i=0;i<n;i++)
	{
		ll a=min(val(q[i].y-1,0),val(q[i].z-1,1))+1;
		anw=max(anw,a);
		upd(q[i].y,0,a),upd(q[i].z,1,a);
	}
	cout<<anw;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 1724 KB Output is correct
2 Correct 13 ms 1684 KB Output is correct
3 Correct 11 ms 1724 KB Output is correct
4 Correct 11 ms 1724 KB Output is correct
5 Correct 12 ms 1664 KB Output is correct
6 Correct 12 ms 1724 KB Output is correct
7 Correct 12 ms 1724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 13 ms 1852 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 1724 KB Output is correct
2 Correct 13 ms 1684 KB Output is correct
3 Correct 11 ms 1724 KB Output is correct
4 Correct 11 ms 1724 KB Output is correct
5 Correct 12 ms 1664 KB Output is correct
6 Correct 12 ms 1724 KB Output is correct
7 Correct 12 ms 1724 KB Output is correct
8 Correct 323 ms 22992 KB Output is correct
9 Correct 267 ms 22744 KB Output is correct
10 Correct 274 ms 22692 KB Output is correct
11 Correct 274 ms 22752 KB Output is correct
12 Correct 308 ms 22712 KB Output is correct
13 Correct 248 ms 22864 KB Output is correct
14 Correct 271 ms 22608 KB Output is correct
15 Correct 271 ms 22608 KB Output is correct
16 Correct 270 ms 22612 KB Output is correct
17 Correct 265 ms 22580 KB Output is correct
18 Correct 306 ms 22696 KB Output is correct
19 Correct 280 ms 22696 KB Output is correct
20 Correct 277 ms 22744 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 13 ms 1852 KB Output isn't correct
2 Halted 0 ms 0 KB -