Submission #106003

#TimeUsernameProblemLanguageResultExecution timeMemory
106003MrTEKtrapezoid (balkan11_trapezoid)C++14
20 / 100
30 ms1152 KiB
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<int,int> ii; const int N = 5e3 + 5; const int mod = 30013; #define ul first.first #define ur first.second #define dl second.first #define dr second.second pair <ii,ii> a[N]; int n,dp[N],cnt[N],ans,ans2; int add(int x,int y) { return x + y >= mod ? x + y - mod : x + y; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n; for (int i = 1 ; i <= n ; i++) cin >> a[i].ul >> a[i].ur >> a[i].dl >> a[i].dr; sort(a + 1,a + n + 1); for (int i = n ; i >= 1 ; i--) { dp[i] = 1; cnt[i] = 1; for (int j = i + 1 ; j <= n ; j++) if (a[i].dr <= a[j].dl) { if (dp[j] + 1 == dp[i]) cnt[i] = add(cnt[i],cnt[j]); if (dp[j] + 1 > dp[i]) { dp[i] = dp[j] + 1; cnt[i] = cnt[j]; } } if (ans < dp[i]) { ans = dp[i]; ans2 = cnt[i]; } else if(ans == dp[i]) ans2 = add(ans2,cnt[i]); } cout << ans << " " << ans2 << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...