답안 #106006

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
106006 2019-04-16T07:25:44 Z MrTEK 사다리꼴 (balkan11_trapezoid) C++14
40 / 100
36 ms 640 KB
#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;
  assert(n <= 5000);
  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 && a[i].ur < a[j].ul) {
        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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 7 ms 384 KB Output is correct
6 Correct 12 ms 384 KB Output is correct
7 Correct 20 ms 512 KB Output is correct
8 Correct 36 ms 512 KB Output is correct
9 Runtime error 3 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 3 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 3 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 3 ms 572 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 4 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 3 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 3 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 3 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 2 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 3 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Runtime error 3 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Runtime error 3 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)