Submission #144270

# Submission time Handle Problem Language Result Execution time Memory
144270 2019-08-16T12:30:18 Z Sorting trapezoid (balkan11_trapezoid) C++14
50 / 100
500 ms 33400 KB
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e5 + 7;
const int mod = 30013;
const int inf = 1e9;

struct trap{
	int a, b, c, d;

	trap(){}
	trap(int a, int b, int c, int d){
		this -> a = a;
		this -> b = b;
		this -> c = c;
		this -> d = d;
	}
};

bool cmp(trap lvalue, trap rvalue){
	return lvalue.a < rvalue.a;
}

pair<int, int> dp[MAXN];
trap t[MAXN];
set<int> st;
map<int, int> mp;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	int n;

	cin >> n;

	for(int i = 1; i <= n; ++i){
		cin >> t[i].a >> t[i].b >> t[i].c >> t[i].d;
		st.insert(t[i].a);
		st.insert(t[i].b);
		st.insert(t[i].c);
		st.insert(t[i].d);
	}

	int cnt = 3;
	for(int x: st){
		mp[x] = cnt++; 
	}
	t[0] = {1, 2, 1, 2};

	for(int i = 1; i <= n; i++){
		t[i].a = mp[t[i].a];
		t[i].b = mp[t[i].b];
		t[i].c = mp[t[i].c];
		t[i].d = mp[t[i].d];
	}

	sort(t, t + n + 1, cmp);

	for(int i = n; i >= 0; --i){
		dp[i] = {1, 1};
		for(int j = i + 1; j <= n; ++j){
			if(t[j].a > t[i].b && t[j].c > t[i].d){
				if(dp[j].first + 1 > dp[i].first){
					dp[i].first = dp[j].first + 1;
					dp[i].second = dp[j].second;
				}
				else{
					if(dp[j].first + 1 == dp[i].first){
						dp[i].second += dp[j].second;
						dp[i].second %= mod;
					}
				}
			}
		}
	}

	cout << dp[0].first - 1 << " " << dp[0].second << "\n";

	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 504 KB Output is correct
4 Correct 5 ms 632 KB Output is correct
5 Correct 11 ms 1144 KB Output is correct
6 Correct 20 ms 1528 KB Output is correct
7 Correct 24 ms 1144 KB Output is correct
8 Correct 36 ms 1912 KB Output is correct
9 Correct 188 ms 4120 KB Output is correct
10 Correct 410 ms 4728 KB Output is correct
11 Execution timed out 935 ms 9872 KB Time limit exceeded
12 Execution timed out 1072 ms 19192 KB Time limit exceeded
13 Execution timed out 1084 ms 21952 KB Time limit exceeded
14 Execution timed out 1079 ms 26724 KB Time limit exceeded
15 Execution timed out 1073 ms 23800 KB Time limit exceeded
16 Execution timed out 1071 ms 25304 KB Time limit exceeded
17 Execution timed out 1067 ms 30600 KB Time limit exceeded
18 Execution timed out 1076 ms 19192 KB Time limit exceeded
19 Execution timed out 1079 ms 32760 KB Time limit exceeded
20 Execution timed out 1076 ms 33400 KB Time limit exceeded