# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
257976 | 2020-08-05T06:57:47 Z | daniel920712 | Boat (APIO16_boat) | C++14 | 2000 ms | 7656 KB |
#include <iostream> #include <stdio.h> #include <stdlib.h> #include <set> #include <map> #include <time.h> using namespace std; long long MOD=1e9+7; long long DP[505][2005]; bool use[505][2005]={0}; long long cha[2005],Con[2005],R[2005]; map < long long , long long > all; long long N,now=0; long long a[505],b[505]; map < long long , long long > con,r; set < long long > have; long long Pow(long long a,long long b) { if(b==0) return 1; long long t=Pow(a,b/2); t*=t; t%=MOD; if(b%2) t*=a; return t%MOD; } long long F(long long x,long long y) { long long i,j,tt; if(x==0) return y!=(now); if(use[x][y]) return DP[x][y]; use[x][y]=1; DP[x][y]=F(x-1,y); for(i=0;i<now;i++) { if(cha[i]>=a[x]&&R[i]<cha[y]&&R[i]<=b[x]) { tt=1; for(j=x;j>=1;j--) { if(cha[i]>=a[j]&&R[i]<cha[y]&&R[i]<=b[j]) { tt*=(Con[i]-(x-j)); tt%=MOD; tt*=Pow(x-j+1,MOD-2); tt%=MOD; //printf("%lld %lld\n",tt,x-j+1); DP[x][y]+=tt*F(j-1,i)%MOD; DP[x][y]%=MOD; } else break; } } } return DP[x][y]; } int main() { long long N,M,i; scanf("%lld",&N); for(i=1;i<=N;i++) { scanf("%lld %lld",&a[i],&b[i]); have.insert(a[i]); have.insert(a[i]+1); have.insert(b[i]); have.insert(b[i]+1); } for(auto i:have) { if(i==*prev(have.end())) { con[i]=1; r[i]=i; } if(have.lower_bound(i)!=have.begin()) { con[*prev(have.lower_bound(i))]=i-*prev(have.lower_bound(i)); r[*prev(have.lower_bound(i))]=i-1; } } for(auto i:con) { cha[now]=i.first; Con[now]=i.second; R[now]=r[i.first]; now++; } cha[now]=1e9+5; Con[now]=0; R[now]=2e9; printf("%lld\n",F(N,now)); return 0; } /* 2 32 47 18 78 */
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 187 ms | 7416 KB | Output is correct |
2 | Correct | 192 ms | 7544 KB | Output is correct |
3 | Correct | 201 ms | 7656 KB | Output is correct |
4 | Correct | 186 ms | 7456 KB | Output is correct |
5 | Correct | 179 ms | 7416 KB | Output is correct |
6 | Correct | 220 ms | 6392 KB | Output is correct |
7 | Correct | 218 ms | 6136 KB | Output is correct |
8 | Correct | 228 ms | 6784 KB | Output is correct |
9 | Correct | 222 ms | 6648 KB | Output is correct |
10 | Correct | 226 ms | 6776 KB | Output is correct |
11 | Correct | 224 ms | 6648 KB | Output is correct |
12 | Correct | 241 ms | 7160 KB | Output is correct |
13 | Correct | 223 ms | 6776 KB | Output is correct |
14 | Correct | 217 ms | 6264 KB | Output is correct |
15 | Correct | 231 ms | 6832 KB | Output is correct |
16 | Correct | 21 ms | 4096 KB | Output is correct |
17 | Correct | 23 ms | 4096 KB | Output is correct |
18 | Correct | 21 ms | 4088 KB | Output is correct |
19 | Correct | 22 ms | 4096 KB | Output is correct |
20 | Correct | 29 ms | 4088 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 187 ms | 7416 KB | Output is correct |
2 | Correct | 192 ms | 7544 KB | Output is correct |
3 | Correct | 201 ms | 7656 KB | Output is correct |
4 | Correct | 186 ms | 7456 KB | Output is correct |
5 | Correct | 179 ms | 7416 KB | Output is correct |
6 | Correct | 220 ms | 6392 KB | Output is correct |
7 | Correct | 218 ms | 6136 KB | Output is correct |
8 | Correct | 228 ms | 6784 KB | Output is correct |
9 | Correct | 222 ms | 6648 KB | Output is correct |
10 | Correct | 226 ms | 6776 KB | Output is correct |
11 | Correct | 224 ms | 6648 KB | Output is correct |
12 | Correct | 241 ms | 7160 KB | Output is correct |
13 | Correct | 223 ms | 6776 KB | Output is correct |
14 | Correct | 217 ms | 6264 KB | Output is correct |
15 | Correct | 231 ms | 6832 KB | Output is correct |
16 | Correct | 21 ms | 4096 KB | Output is correct |
17 | Correct | 23 ms | 4096 KB | Output is correct |
18 | Correct | 21 ms | 4088 KB | Output is correct |
19 | Correct | 22 ms | 4096 KB | Output is correct |
20 | Correct | 29 ms | 4088 KB | Output is correct |
21 | Execution timed out | 2065 ms | 1852 KB | Time limit exceeded |
22 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1759 ms | 1400 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 187 ms | 7416 KB | Output is correct |
2 | Correct | 192 ms | 7544 KB | Output is correct |
3 | Correct | 201 ms | 7656 KB | Output is correct |
4 | Correct | 186 ms | 7456 KB | Output is correct |
5 | Correct | 179 ms | 7416 KB | Output is correct |
6 | Correct | 220 ms | 6392 KB | Output is correct |
7 | Correct | 218 ms | 6136 KB | Output is correct |
8 | Correct | 228 ms | 6784 KB | Output is correct |
9 | Correct | 222 ms | 6648 KB | Output is correct |
10 | Correct | 226 ms | 6776 KB | Output is correct |
11 | Correct | 224 ms | 6648 KB | Output is correct |
12 | Correct | 241 ms | 7160 KB | Output is correct |
13 | Correct | 223 ms | 6776 KB | Output is correct |
14 | Correct | 217 ms | 6264 KB | Output is correct |
15 | Correct | 231 ms | 6832 KB | Output is correct |
16 | Correct | 21 ms | 4096 KB | Output is correct |
17 | Correct | 23 ms | 4096 KB | Output is correct |
18 | Correct | 21 ms | 4088 KB | Output is correct |
19 | Correct | 22 ms | 4096 KB | Output is correct |
20 | Correct | 29 ms | 4088 KB | Output is correct |
21 | Execution timed out | 2065 ms | 1852 KB | Time limit exceeded |
22 | Halted | 0 ms | 0 KB | - |