답안 #125736

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
125736 2019-07-06T09:47:47 Z faustaadp 사다리꼴 (balkan11_trapezoid) C++17
8 / 100
500 ms 18284 KB
#include<bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
int n,i,ta,tb,tc,td,j,h1,h2,d[101010],d2[101010],mo=30013,K;
vector<int> v[101010],z;
pair<pair<int,int>,pair<int,int> > A[101010];
map<int,int> me;
int depe(int aa)
{
	if(d[aa]==-1)
	{
		d[aa]=0;
		int ii;
		for(ii=0;ii<v[aa].size();ii++)
			d[aa]=max(d[aa],depe(v[aa][ii]));
		d[aa]++;
	}
	return d[aa];
}
int depe2(int aa)
{
	if(depe(aa)==1)return 1;
	if(d2[aa]==-1)
	{
		d2[aa]=0;
		int ii;
		for(ii=0;ii<v[aa].size();ii++)
			if(depe(aa)==depe(v[aa][ii])+1)
				d2[aa]=(d2[aa]+depe2(v[aa][ii]))%mo;
	}
	return d2[aa];
}
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	K=1000000001;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>ta>>tb>>tc>>td;
		A[i]=mp(mp(ta,tb),mp(tc,td));
		z.pb(tc);
		z.pb(td+1);
	}
	sort(z.begin(),z.end());
	for(i=0;i<z.size();i++)
		me[z[i]]=i+1;
	for(i=1;i<=n;i++)
	{
		A[i].se.fi=me[A[i].se.fi];
		A[i].se.se=me[A[i].se.se];
	}
	if(1)
	{
		sort(A+1,A+1+n);
		for(i=1;i<=n;i++)
		{
			int L=i+1,R=n,C,H=0;
			while(L<=R)
			{
				C=(L+R)/2;
				if(A[i].fi.se<A[C].fi.fi)
				{
					H=C;
					R=C-1;
				}
				else
					L=C+1;
			}
			if(H)
				v[H].pb(i);
		}
		//return 0;
		for(i=n;i>=1;i--)d[i]=1;
		for(i=n;i>=1;i--)
		{
			for(j=0;j<v[i].size();j++)
			{
				int now=v[i][j];
				ll k;
				for(k=i;k<=n;k++)
					if(A[now].se.se<A[k].se.fi)
						d[now]=max(d[now],d[k]+1);
			}
			h1=max(h1,d[i]);
		}
	}
	else
	{
		for(i=1;i<=n;i++)
			for(j=1;j<=n;j++)
				if(A[i].fi.se<A[j].fi.fi&&A[i].se.se<A[j].se.fi)
					v[i].pb(j);
		memset(d,-1,sizeof(d));
		memset(d2,-1,sizeof(d2));
		for(i=1;i<=n;i++)
			h1=max(h1,depe(i));
		for(i=1;i<=n;i++)
			if(depe(i)==h1)
				h2=(h2+depe2(i))%mo;
	}
	cout<<h1<<" "<<h2<<"\n";	
}

Compilation message

trapezoid.cpp: In function 'int depe(int)':
trapezoid.cpp:18:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(ii=0;ii<v[aa].size();ii++)
            ~~^~~~~~~~~~~~~
trapezoid.cpp: In function 'int depe2(int)':
trapezoid.cpp:31:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(ii=0;ii<v[aa].size();ii++)
            ~~^~~~~~~~~~~~~
trapezoid.cpp: In function 'int main()':
trapezoid.cpp:50:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(i=0;i<z.size();i++)
          ~^~~~~~~~~
trapezoid.cpp:81:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(j=0;j<v[i].size();j++)
            ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Partially correct 4 ms 2680 KB Partially correct
2 Partially correct 4 ms 2812 KB Partially correct
3 Incorrect 5 ms 2808 KB Output isn't correct
4 Partially correct 7 ms 2936 KB Partially correct
5 Incorrect 12 ms 3064 KB Output isn't correct
6 Incorrect 22 ms 3220 KB Output isn't correct
7 Partially correct 32 ms 3448 KB Partially correct
8 Incorrect 27 ms 3448 KB Output isn't correct
9 Incorrect 154 ms 4088 KB Output isn't correct
10 Execution timed out 629 ms 6136 KB Time limit exceeded
11 Execution timed out 968 ms 6776 KB Time limit exceeded
12 Execution timed out 1076 ms 11124 KB Time limit exceeded
13 Execution timed out 1081 ms 12788 KB Time limit exceeded
14 Execution timed out 1076 ms 15088 KB Time limit exceeded
15 Execution timed out 1077 ms 14320 KB Time limit exceeded
16 Execution timed out 1084 ms 15780 KB Time limit exceeded
17 Execution timed out 1084 ms 17008 KB Time limit exceeded
18 Execution timed out 1082 ms 16236 KB Time limit exceeded
19 Execution timed out 1089 ms 17392 KB Time limit exceeded
20 Execution timed out 1086 ms 18284 KB Time limit exceeded