Submission #125668

# Submission time Handle Problem Language Result Execution time Memory
125668 2019-07-06T07:48:02 Z faustaadp trapezoid (balkan11_trapezoid) C++17
40 / 100
302 ms 65540 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;
vector<int> v[101010];
pair<pair<int,int>,pair<int,int> > A[101010];
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];
}
ll depe2(ll 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);
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>ta>>tb>>tc>>td;
		A[i]=mp(mp(ta,tb),mp(tc,td));
	}
	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:17:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(ii=0;ii<v[aa].size();ii++)
            ~~^~~~~~~~~~~~~
trapezoid.cpp: In function 'll depe2(ll)':
trapezoid.cpp:30:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(ii=0;ii<v[aa].size();ii++)
            ~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 3448 KB Output is correct
2 Correct 5 ms 3576 KB Output is correct
3 Correct 8 ms 4088 KB Output is correct
4 Correct 17 ms 6008 KB Output is correct
5 Correct 42 ms 11644 KB Output is correct
6 Correct 99 ms 23544 KB Output is correct
7 Correct 166 ms 41040 KB Output is correct
8 Correct 130 ms 15352 KB Output is correct
9 Runtime error 237 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Runtime error 207 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
11 Runtime error 216 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
12 Runtime error 258 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
13 Runtime error 257 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
14 Runtime error 248 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
15 Runtime error 264 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
16 Runtime error 266 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
17 Runtime error 302 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
18 Runtime error 272 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
19 Runtime error 290 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
20 Runtime error 290 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)