Submission #243904

#TimeUsernameProblemLanguageResultExecution timeMemory
243904abacabatrapezoid (balkan11_trapezoid)C++14
45 / 100
1096 ms2296 KiB
#include <iostream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <chrono>
#include <vector>
#include <map>
#include <random>
#include <set>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <stdio.h>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <deque>
#include <cassert>
#include <stack>
using namespace std;
 
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ppb pop_back
#define emb emplace_back
#define ll long long
#define ull unsigned long long
#define cntbit(x) __builtin_popcount(x)
#define endl '\n'
#define uset unordered_set
#define umap unordered_map
#define pii pair<int, int>
#define ld long double
#define pll pair<long long, long long>
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template <typename T> inline T range(T l, T r) {
    return uniform_int_distribution<T>(l, r)(rng);
}
 
inline void setin(string s) {
    freopen(s.c_str(), "r", stdin);
}
 
inline void setout(string s) {
    freopen(s.c_str(), "w", stdout);
}
 
template <typename T> void Min(T &a, T b) {
    a = min(a, b);
}
 
template <typename T> void Max(T &a, T b) {
    a = max(a, b);
}

const int mod = 30013;
const int inf = 0x3f3f3f3f;
const int N = 1e5 + 15;
int n;

struct pt {
    int l1, r1, l2, r2;
    bool operator < (const pt &rhs) const {
        return mp(l2, r2) < mp(rhs.l2, rhs.r2);
    }
} a[N];

pii dp[N];

inline bool lie(int l, int x, int r) {
    return l <= x && x <= r;
}

inline pii merge(pii a, pii b) {
    if(a.f == b.f)
        return mp(a.f, (a.se + b.se) % mod);
    return max(a, b);
}

main() {
    ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);
    // setin("input.txt");
    cin >> n;
    for(int i = 1; i <= n; ++i)
        cin >> a[i].l1 >> a[i].r1 >> a[i].l2 >> a[i].r2;
    sort(a + 1, a + 1 + n);
    for(int i = 1; i <= n; ++i) {
        dp[i] = {1, 1};
        for(int j = 1; j < i; ++j) {
            if(a[j].r2 < a[i].l2 && a[j].r1 < a[i].l1)
                dp[i] = merge(dp[i], mp(dp[j].f + 1, dp[j].se));
        }
    }
    pii ans(0, 0);
    for(int i = 1; i <= n; ++i)
        ans = merge(ans, dp[i]);
    cout << ans.f << ' ' << ans.se << endl;
    return 0;
}

Compilation message (stderr)

trapezoid.cpp:85:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
#Verdict Execution timeMemoryGrader output
Fetching results...