Submission #144270

#TimeUsernameProblemLanguageResultExecution timeMemory
144270Sortingtrapezoid (balkan11_trapezoid)C++14
50 / 100
1084 ms33400 KiB
#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 timeMemoryGrader output
Fetching results...