답안 #725805

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
725805 2023-04-18T05:54:29 Z quiet_space Boat (APIO16_boat) C++14
100 / 100
294 ms 340 KB
#include <bits/stdc++.h>
#define FOR(i,j,k) for(int i=j; i<=k; ++i)
#define ROF(i,j,k) for(int i=j; i>=k; --i)
inline int read (void) {
  int x = 0, f = 1, ch = getchar();
  while(!isdigit(ch)) { if(ch == '-') f = -f; ch = getchar(); }
  while(isdigit(ch)) { x = x * 10 + ch - '0'; ch = getchar(); }
  return x * f;
}
const int maxn = 505;
const int mod = 1000000007;
inline void inc (int&x, int y) { (x += y) >= mod ? x -= mod : x; }
int l[maxn], r[maxn], totb, b[maxn<<1], inv[maxn], c[maxn], g[maxn];
int main (void) {
  int n = read();
  inv[1] = 1;
  FOR(i,2,n) inv[i] = 1ll * (mod - mod / i) * inv[mod % i] % mod;
  FOR(i,1,n) b[++ totb] = l[i] = read(), b[++ totb] = r[i] = read() + 1;
  std::sort(b+1, b+totb+1);
  totb = std::unique(b+1, b+totb+1) - b - 1;
  FOR(i,1,n) l[i] = std::lower_bound (b+1, b+totb+1, l[i]) - b, r[i] = std::lower_bound (b+1, b+totb+1, r[i]) - b;
  c[0] = g[0] = 1;
  FOR(j,1,totb-1) {
    int len = b[j + 1] - b[j];
    FOR(i,1,n) c[i] = 1ll * c[i-1] * (len + i - 1) % mod * inv[i] % mod;
    ROF(i,n,1) if(l[i] <= j && j < r[i]) {
      int f = 0, cnt = 1;
      ROF(k,i-1,0) {
        f = (f + 1ll * c[cnt] * g[k]) % mod;
        if(l[k] <= j && j < r[k]) ++ cnt;
      }
      inc (g[i], f);
    }
  }
  int ans = 0;
  FOR(i,1,n) inc (ans, g[i]);
  printf("%d\n", ans);
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 212 KB Output is correct
2 Correct 8 ms 316 KB Output is correct
3 Correct 9 ms 212 KB Output is correct
4 Correct 8 ms 324 KB Output is correct
5 Correct 9 ms 312 KB Output is correct
6 Correct 8 ms 324 KB Output is correct
7 Correct 8 ms 328 KB Output is correct
8 Correct 8 ms 212 KB Output is correct
9 Correct 8 ms 340 KB Output is correct
10 Correct 8 ms 212 KB Output is correct
11 Correct 8 ms 212 KB Output is correct
12 Correct 8 ms 212 KB Output is correct
13 Correct 8 ms 212 KB Output is correct
14 Correct 8 ms 212 KB Output is correct
15 Correct 7 ms 212 KB Output is correct
16 Correct 3 ms 212 KB Output is correct
17 Correct 3 ms 312 KB Output is correct
18 Correct 3 ms 212 KB Output is correct
19 Correct 2 ms 212 KB Output is correct
20 Correct 3 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 212 KB Output is correct
2 Correct 8 ms 316 KB Output is correct
3 Correct 9 ms 212 KB Output is correct
4 Correct 8 ms 324 KB Output is correct
5 Correct 9 ms 312 KB Output is correct
6 Correct 8 ms 324 KB Output is correct
7 Correct 8 ms 328 KB Output is correct
8 Correct 8 ms 212 KB Output is correct
9 Correct 8 ms 340 KB Output is correct
10 Correct 8 ms 212 KB Output is correct
11 Correct 8 ms 212 KB Output is correct
12 Correct 8 ms 212 KB Output is correct
13 Correct 8 ms 212 KB Output is correct
14 Correct 8 ms 212 KB Output is correct
15 Correct 7 ms 212 KB Output is correct
16 Correct 3 ms 212 KB Output is correct
17 Correct 3 ms 312 KB Output is correct
18 Correct 3 ms 212 KB Output is correct
19 Correct 2 ms 212 KB Output is correct
20 Correct 3 ms 212 KB Output is correct
21 Correct 185 ms 312 KB Output is correct
22 Correct 175 ms 304 KB Output is correct
23 Correct 161 ms 300 KB Output is correct
24 Correct 178 ms 296 KB Output is correct
25 Correct 171 ms 300 KB Output is correct
26 Correct 251 ms 300 KB Output is correct
27 Correct 248 ms 332 KB Output is correct
28 Correct 247 ms 296 KB Output is correct
29 Correct 250 ms 212 KB Output is correct
30 Correct 9 ms 212 KB Output is correct
31 Correct 9 ms 312 KB Output is correct
32 Correct 9 ms 316 KB Output is correct
33 Correct 9 ms 212 KB Output is correct
34 Correct 9 ms 320 KB Output is correct
35 Correct 9 ms 316 KB Output is correct
36 Correct 10 ms 316 KB Output is correct
37 Correct 10 ms 320 KB Output is correct
38 Correct 10 ms 324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 2 ms 304 KB Output is correct
3 Correct 2 ms 308 KB Output is correct
4 Correct 3 ms 212 KB Output is correct
5 Correct 2 ms 212 KB Output is correct
6 Correct 3 ms 212 KB Output is correct
7 Correct 3 ms 312 KB Output is correct
8 Correct 3 ms 212 KB Output is correct
9 Correct 3 ms 212 KB Output is correct
10 Correct 3 ms 212 KB Output is correct
11 Correct 2 ms 212 KB Output is correct
12 Correct 2 ms 304 KB Output is correct
13 Correct 2 ms 212 KB Output is correct
14 Correct 2 ms 212 KB Output is correct
15 Correct 3 ms 212 KB Output is correct
16 Correct 2 ms 212 KB Output is correct
17 Correct 2 ms 212 KB Output is correct
18 Correct 2 ms 212 KB Output is correct
19 Correct 2 ms 212 KB Output is correct
20 Correct 2 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 212 KB Output is correct
2 Correct 8 ms 316 KB Output is correct
3 Correct 9 ms 212 KB Output is correct
4 Correct 8 ms 324 KB Output is correct
5 Correct 9 ms 312 KB Output is correct
6 Correct 8 ms 324 KB Output is correct
7 Correct 8 ms 328 KB Output is correct
8 Correct 8 ms 212 KB Output is correct
9 Correct 8 ms 340 KB Output is correct
10 Correct 8 ms 212 KB Output is correct
11 Correct 8 ms 212 KB Output is correct
12 Correct 8 ms 212 KB Output is correct
13 Correct 8 ms 212 KB Output is correct
14 Correct 8 ms 212 KB Output is correct
15 Correct 7 ms 212 KB Output is correct
16 Correct 3 ms 212 KB Output is correct
17 Correct 3 ms 312 KB Output is correct
18 Correct 3 ms 212 KB Output is correct
19 Correct 2 ms 212 KB Output is correct
20 Correct 3 ms 212 KB Output is correct
21 Correct 185 ms 312 KB Output is correct
22 Correct 175 ms 304 KB Output is correct
23 Correct 161 ms 300 KB Output is correct
24 Correct 178 ms 296 KB Output is correct
25 Correct 171 ms 300 KB Output is correct
26 Correct 251 ms 300 KB Output is correct
27 Correct 248 ms 332 KB Output is correct
28 Correct 247 ms 296 KB Output is correct
29 Correct 250 ms 212 KB Output is correct
30 Correct 9 ms 212 KB Output is correct
31 Correct 9 ms 312 KB Output is correct
32 Correct 9 ms 316 KB Output is correct
33 Correct 9 ms 212 KB Output is correct
34 Correct 9 ms 320 KB Output is correct
35 Correct 9 ms 316 KB Output is correct
36 Correct 10 ms 316 KB Output is correct
37 Correct 10 ms 320 KB Output is correct
38 Correct 10 ms 324 KB Output is correct
39 Correct 2 ms 340 KB Output is correct
40 Correct 2 ms 304 KB Output is correct
41 Correct 2 ms 308 KB Output is correct
42 Correct 3 ms 212 KB Output is correct
43 Correct 2 ms 212 KB Output is correct
44 Correct 3 ms 212 KB Output is correct
45 Correct 3 ms 312 KB Output is correct
46 Correct 3 ms 212 KB Output is correct
47 Correct 3 ms 212 KB Output is correct
48 Correct 3 ms 212 KB Output is correct
49 Correct 2 ms 212 KB Output is correct
50 Correct 2 ms 304 KB Output is correct
51 Correct 2 ms 212 KB Output is correct
52 Correct 2 ms 212 KB Output is correct
53 Correct 3 ms 212 KB Output is correct
54 Correct 2 ms 212 KB Output is correct
55 Correct 2 ms 212 KB Output is correct
56 Correct 2 ms 212 KB Output is correct
57 Correct 2 ms 212 KB Output is correct
58 Correct 2 ms 212 KB Output is correct
59 Correct 197 ms 212 KB Output is correct
60 Correct 206 ms 212 KB Output is correct
61 Correct 177 ms 304 KB Output is correct
62 Correct 205 ms 304 KB Output is correct
63 Correct 199 ms 212 KB Output is correct
64 Correct 283 ms 304 KB Output is correct
65 Correct 294 ms 316 KB Output is correct
66 Correct 282 ms 304 KB Output is correct
67 Correct 286 ms 304 KB Output is correct
68 Correct 276 ms 316 KB Output is correct
69 Correct 152 ms 304 KB Output is correct
70 Correct 147 ms 316 KB Output is correct
71 Correct 144 ms 300 KB Output is correct
72 Correct 159 ms 304 KB Output is correct
73 Correct 159 ms 308 KB Output is correct
74 Correct 38 ms 304 KB Output is correct
75 Correct 37 ms 320 KB Output is correct
76 Correct 38 ms 212 KB Output is correct
77 Correct 38 ms 324 KB Output is correct
78 Correct 40 ms 212 KB Output is correct