# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
48379 | 2018-05-12T11:17:13 Z | BThero | Boat (APIO16_boat) | C++17 | 2000 ms | 524288 KB |
// Why am I so stupid? :c #include <bits/stdc++.h> #define pb push_back #define mp make_pair #define all(x) (x).begin(), (x).end() #define fi first #define se second typedef long long ll; using namespace std; const int mod = 1e9+7; pair <int, int> l[505]; pair <int, int> r[505]; int dp[2][1000005]; int dp2[1000005]; int rl[1005]; int n, m; int ans; int now; void addMod(int &a, int b) { a += b; if (mod <= a) { a -= mod; } } void compress() { vector <int> vv; for (int i = 1; i <= n; ++i) { for (int j = l[i].fi; j <= r[i].fi; ++j) { vv.pb(j); } } sort(all(vv)); vv.resize(unique(all(vv)) - vv.begin()); m = vv.size(); for (int i = 1; i <= n; ++i) { l[i].se = upper_bound(all(vv), l[i].fi) - vv.begin(); r[i].se = upper_bound(all(vv), r[i].fi) - vv.begin(); } } void solve() { scanf("%d", &n); for (int i = 1; i <= n; ++i) { scanf("%d %d", &l[i].fi, &r[i].fi); } compress(); for (int i = 1; i <= n; ++i) { now ^= 1; for (int j = l[i].se; j <= r[i].se; ++j) { dp[now][j] = 1; } for (int j = l[i].se; j <= r[i].se; ++j) { for (int k = 1; k < j; ++k) { addMod(dp[now][j], dp2[k]); } } for (int j = l[i].se; j <= r[i].se; ++j) { addMod(dp2[j], dp[now][j]); } } for (int i = 1; i <= m; ++i) { addMod(ans, dp2[i]); } printf("%d\n", ans); } int main() { #ifdef BThero freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif // BThero int tt = 1; while (tt--) { solve(); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 428 KB | Output is correct |
4 | Correct | 2 ms | 504 KB | Output is correct |
5 | Correct | 2 ms | 580 KB | Output is correct |
6 | Correct | 2 ms | 580 KB | Output is correct |
7 | Correct | 2 ms | 580 KB | Output is correct |
8 | Correct | 2 ms | 580 KB | Output is correct |
9 | Correct | 2 ms | 580 KB | Output is correct |
10 | Correct | 2 ms | 580 KB | Output is correct |
11 | Correct | 2 ms | 612 KB | Output is correct |
12 | Correct | 2 ms | 612 KB | Output is correct |
13 | Correct | 2 ms | 612 KB | Output is correct |
14 | Correct | 2 ms | 616 KB | Output is correct |
15 | Correct | 2 ms | 712 KB | Output is correct |
16 | Correct | 2 ms | 712 KB | Output is correct |
17 | Correct | 2 ms | 712 KB | Output is correct |
18 | Correct | 2 ms | 712 KB | Output is correct |
19 | Correct | 2 ms | 712 KB | Output is correct |
20 | Correct | 2 ms | 712 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 428 KB | Output is correct |
4 | Correct | 2 ms | 504 KB | Output is correct |
5 | Correct | 2 ms | 580 KB | Output is correct |
6 | Correct | 2 ms | 580 KB | Output is correct |
7 | Correct | 2 ms | 580 KB | Output is correct |
8 | Correct | 2 ms | 580 KB | Output is correct |
9 | Correct | 2 ms | 580 KB | Output is correct |
10 | Correct | 2 ms | 580 KB | Output is correct |
11 | Correct | 2 ms | 612 KB | Output is correct |
12 | Correct | 2 ms | 612 KB | Output is correct |
13 | Correct | 2 ms | 612 KB | Output is correct |
14 | Correct | 2 ms | 616 KB | Output is correct |
15 | Correct | 2 ms | 712 KB | Output is correct |
16 | Correct | 2 ms | 712 KB | Output is correct |
17 | Correct | 2 ms | 712 KB | Output is correct |
18 | Correct | 2 ms | 712 KB | Output is correct |
19 | Correct | 2 ms | 712 KB | Output is correct |
20 | Correct | 2 ms | 712 KB | Output is correct |
21 | Execution timed out | 2061 ms | 4816 KB | Time limit exceeded |
22 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 785 ms | 524288 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 428 KB | Output is correct |
4 | Correct | 2 ms | 504 KB | Output is correct |
5 | Correct | 2 ms | 580 KB | Output is correct |
6 | Correct | 2 ms | 580 KB | Output is correct |
7 | Correct | 2 ms | 580 KB | Output is correct |
8 | Correct | 2 ms | 580 KB | Output is correct |
9 | Correct | 2 ms | 580 KB | Output is correct |
10 | Correct | 2 ms | 580 KB | Output is correct |
11 | Correct | 2 ms | 612 KB | Output is correct |
12 | Correct | 2 ms | 612 KB | Output is correct |
13 | Correct | 2 ms | 612 KB | Output is correct |
14 | Correct | 2 ms | 616 KB | Output is correct |
15 | Correct | 2 ms | 712 KB | Output is correct |
16 | Correct | 2 ms | 712 KB | Output is correct |
17 | Correct | 2 ms | 712 KB | Output is correct |
18 | Correct | 2 ms | 712 KB | Output is correct |
19 | Correct | 2 ms | 712 KB | Output is correct |
20 | Correct | 2 ms | 712 KB | Output is correct |
21 | Execution timed out | 2061 ms | 4816 KB | Time limit exceeded |
22 | Halted | 0 ms | 0 KB | - |