# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
889318 | borisAngelov | 사다리꼴 (balkan11_trapezoid) | C++17 | 1067 ms | 2900 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
const int mod = 30013;
int n;
struct Segment
{
int x;
int y;
};
bool cross(const Segment& fr, const Segment& sc)
{
return fr.x <= sc.y && fr.y >= sc.x;
}
struct Trapezoid
{
Segment up;
Segment down;
};
Trapezoid a[maxn];
pair<int, int> dp[maxn];
void fastIO()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
int main()
{
fastIO();
cin >> n;
for (int i = 1; i <= n; ++i)
{
cin >> a[i].up.x >> a[i].up.y >> a[i].down.x >> a[i].down.y;
}
sort(a + 1, a + n + 1, [&](const Trapezoid& fr, const Trapezoid& sc)
{
return fr.down.x < sc.down.x;
});
for (int i = 1; i <= n; ++i)
{
dp[i].first = 1;
dp[i].second = 1;
for (int j = i - 1; j >= 1; --j)
{
if (a[i].down.x > a[j].down.y && a[i].up.x > a[j].up.y)
{
//cout << i << ' ' << j << endl;
if (dp[i].first < 1 + dp[j].first)
{
dp[i].first = 1 + dp[j].first;
dp[i].second = dp[j].second;
}
else if (dp[i].first == 1 + dp[j].first)
{
dp[i].second += dp[j].second;
if (dp[i].second >= mod)
{
dp[i].second -= mod;
}
}
}
}
}
int mx = 0;
int cnt = 0;
for (int i = 1; i <= n; ++i)
{
if (mx < dp[i].first)
{
mx = dp[i].first;
cnt = dp[i].second;
}
else if (mx == dp[i].first)
{
cnt += dp[i].second;
if (cnt >= mod)
{
cnt -= mod;
}
}
}
cout << mx << ' ' << cnt << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |