Submission #908002

# Submission time Handle Problem Language Result Execution time Memory
908002 2024-01-16T07:03:52 Z 12345678 trapezoid (balkan11_trapezoid) C++17
45 / 100
500 ms 5640 KB
#include <bits/stdc++.h>

using namespace std;

const int nx=1e5+5, mod=30013;

struct trapezoid
{
    int a=0, b=0, c=0, d=0;
    bool operator< (const trapezoid &o) const {
        return a<o.a;
    }
} s[nx];

int n, dp[nx], cnt[nx], mx, res;

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>n;
    for (int i=1; i<=n; i++) cin>>s[i].a>>s[i].b>>s[i].c>>s[i].d;
    sort(s+1, s+n+1);
    cnt[0]=1;
    for (int i=1; i<=n; i++)
    {
        for (int j=0; j<i; j++) 
        {
            if (s[i].a>s[j].b&&s[i].c>s[j].d) 
            {
                if (dp[j]+1>dp[i]) dp[i]=dp[j]+1, cnt[i]=cnt[j];
                else if (dp[j]+1==dp[i]) cnt[i]=(cnt[i]+cnt[j])%mod;
            }
        }
        mx=max(mx, dp[i]);
    }
    for (int i=1; i<=n; i++) if (dp[i]==mx) res=(res+cnt[i])%mod;
    cout<<mx<<' '<<res;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 3 ms 2396 KB Output is correct
5 Correct 6 ms 2396 KB Output is correct
6 Correct 11 ms 2588 KB Output is correct
7 Correct 30 ms 2396 KB Output is correct
8 Correct 22 ms 2640 KB Output is correct
9 Correct 120 ms 2752 KB Output is correct
10 Execution timed out 748 ms 3412 KB Time limit exceeded
11 Execution timed out 832 ms 3492 KB Time limit exceeded
12 Execution timed out 1033 ms 4040 KB Time limit exceeded
13 Execution timed out 1012 ms 4180 KB Time limit exceeded
14 Execution timed out 1048 ms 4560 KB Time limit exceeded
15 Execution timed out 1035 ms 4780 KB Time limit exceeded
16 Execution timed out 1076 ms 4748 KB Time limit exceeded
17 Execution timed out 1059 ms 4908 KB Time limit exceeded
18 Execution timed out 1066 ms 4996 KB Time limit exceeded
19 Execution timed out 1036 ms 5640 KB Time limit exceeded
20 Execution timed out 1053 ms 5356 KB Time limit exceeded