# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
50352 |
2018-06-10T17:37:47 Z |
duality |
Boat (APIO16_boat) |
C++11 |
|
877 ms |
5256 KB |
#include <bits/stdc++.h>
using namespace std;
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}
// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
public:
template<typename T>
_Debug& operator,(T val) {
cout << val << endl;
return *this;
}
};
#define debug _Debug(),
// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;
// ---------- END OF TEMPLATE ----------
#define MOD 1000000007
int a[500],b[500];
vi l;
LLI inv[501];
LLI dp[500][1000];
int main() {
int i;
int N;
scanf("%d",&N);
for (i = 0; i < N; i++) scanf("%d %d",&a[i],&b[i]),b[i]++,l.push_back(a[i]),l.push_back(b[i]);
l.push_back(-1);
sort(l.begin(),l.end());
l.resize(unique(l.begin(),l.end())-l.begin());
int j,k;
int s = 0,x;
LLI w;
for (i = 1; i <= N; i++) {
int e = MOD-2;
LLI r = 1,b = i;
while (e > 0) {
if (e & 1) r *= b,r %= MOD;
e >>= 1;
b *= b,b %= MOD;
}
inv[i] = r;
}
for (i = 0; i < N; i++) {
for (j = 1; j < (l.size()-1); j++) {
w = 1,x = 0;
dp[i][j] = dp[i][j-1];
for (k = i; k >= 0; k--) {
if ((l[j] >= a[k]) && (l[j+1] <= b[k])) {
w *= l[j+1]-l[j]+x,w %= MOD;
w *= inv[x+1],w %= MOD;
x++;
}
else if (k == i) break;
if (k == 0) dp[i][j] += w;
else dp[i][j] += w*dp[k-1][j-1];
dp[i][j] %= MOD;
}
}
s += dp[i][l.size()-2],s %= MOD;
}
printf("%d\n",s);
return 0;
}
Compilation message
boat.cpp: In function 'int main()':
boat.cpp:72:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (j = 1; j < (l.size()-1); j++) {
~~^~~~~~~~~~~~~~
boat.cpp:52:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&N);
~~~~~^~~~~~~~~
boat.cpp:53:80: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
for (i = 0; i < N; i++) scanf("%d %d",&a[i],&b[i]),b[i]++,l.push_back(a[i]),l.push_back(b[i]);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
4216 KB |
Output is correct |
2 |
Correct |
7 ms |
4360 KB |
Output is correct |
3 |
Correct |
7 ms |
4384 KB |
Output is correct |
4 |
Correct |
7 ms |
4416 KB |
Output is correct |
5 |
Correct |
6 ms |
4416 KB |
Output is correct |
6 |
Correct |
7 ms |
4416 KB |
Output is correct |
7 |
Correct |
7 ms |
4416 KB |
Output is correct |
8 |
Correct |
7 ms |
4416 KB |
Output is correct |
9 |
Correct |
9 ms |
4416 KB |
Output is correct |
10 |
Correct |
7 ms |
4416 KB |
Output is correct |
11 |
Correct |
7 ms |
4416 KB |
Output is correct |
12 |
Correct |
7 ms |
4416 KB |
Output is correct |
13 |
Correct |
6 ms |
4432 KB |
Output is correct |
14 |
Correct |
8 ms |
4476 KB |
Output is correct |
15 |
Correct |
7 ms |
4476 KB |
Output is correct |
16 |
Correct |
6 ms |
4476 KB |
Output is correct |
17 |
Correct |
7 ms |
4476 KB |
Output is correct |
18 |
Correct |
6 ms |
4476 KB |
Output is correct |
19 |
Correct |
6 ms |
4476 KB |
Output is correct |
20 |
Correct |
7 ms |
4476 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
4216 KB |
Output is correct |
2 |
Correct |
7 ms |
4360 KB |
Output is correct |
3 |
Correct |
7 ms |
4384 KB |
Output is correct |
4 |
Correct |
7 ms |
4416 KB |
Output is correct |
5 |
Correct |
6 ms |
4416 KB |
Output is correct |
6 |
Correct |
7 ms |
4416 KB |
Output is correct |
7 |
Correct |
7 ms |
4416 KB |
Output is correct |
8 |
Correct |
7 ms |
4416 KB |
Output is correct |
9 |
Correct |
9 ms |
4416 KB |
Output is correct |
10 |
Correct |
7 ms |
4416 KB |
Output is correct |
11 |
Correct |
7 ms |
4416 KB |
Output is correct |
12 |
Correct |
7 ms |
4416 KB |
Output is correct |
13 |
Correct |
6 ms |
4432 KB |
Output is correct |
14 |
Correct |
8 ms |
4476 KB |
Output is correct |
15 |
Correct |
7 ms |
4476 KB |
Output is correct |
16 |
Correct |
6 ms |
4476 KB |
Output is correct |
17 |
Correct |
7 ms |
4476 KB |
Output is correct |
18 |
Correct |
6 ms |
4476 KB |
Output is correct |
19 |
Correct |
6 ms |
4476 KB |
Output is correct |
20 |
Correct |
7 ms |
4476 KB |
Output is correct |
21 |
Correct |
362 ms |
4476 KB |
Output is correct |
22 |
Correct |
362 ms |
4604 KB |
Output is correct |
23 |
Correct |
302 ms |
4604 KB |
Output is correct |
24 |
Correct |
391 ms |
4668 KB |
Output is correct |
25 |
Correct |
322 ms |
4668 KB |
Output is correct |
26 |
Correct |
651 ms |
4744 KB |
Output is correct |
27 |
Correct |
653 ms |
4776 KB |
Output is correct |
28 |
Correct |
662 ms |
4852 KB |
Output is correct |
29 |
Correct |
684 ms |
4852 KB |
Output is correct |
30 |
Correct |
9 ms |
4852 KB |
Output is correct |
31 |
Correct |
10 ms |
4852 KB |
Output is correct |
32 |
Correct |
9 ms |
4852 KB |
Output is correct |
33 |
Correct |
9 ms |
4852 KB |
Output is correct |
34 |
Correct |
9 ms |
4852 KB |
Output is correct |
35 |
Correct |
11 ms |
4852 KB |
Output is correct |
36 |
Correct |
11 ms |
4852 KB |
Output is correct |
37 |
Correct |
10 ms |
4852 KB |
Output is correct |
38 |
Correct |
11 ms |
4852 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
4852 KB |
Output is correct |
2 |
Correct |
5 ms |
4852 KB |
Output is correct |
3 |
Correct |
5 ms |
4852 KB |
Output is correct |
4 |
Correct |
5 ms |
4852 KB |
Output is correct |
5 |
Correct |
6 ms |
4852 KB |
Output is correct |
6 |
Correct |
9 ms |
4852 KB |
Output is correct |
7 |
Correct |
8 ms |
4852 KB |
Output is correct |
8 |
Correct |
8 ms |
4852 KB |
Output is correct |
9 |
Correct |
9 ms |
4852 KB |
Output is correct |
10 |
Correct |
8 ms |
4852 KB |
Output is correct |
11 |
Correct |
5 ms |
4852 KB |
Output is correct |
12 |
Correct |
5 ms |
4852 KB |
Output is correct |
13 |
Correct |
5 ms |
4852 KB |
Output is correct |
14 |
Correct |
5 ms |
4852 KB |
Output is correct |
15 |
Correct |
5 ms |
4852 KB |
Output is correct |
16 |
Correct |
5 ms |
4852 KB |
Output is correct |
17 |
Correct |
4 ms |
4852 KB |
Output is correct |
18 |
Correct |
4 ms |
4852 KB |
Output is correct |
19 |
Correct |
4 ms |
4852 KB |
Output is correct |
20 |
Correct |
4 ms |
4852 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
4216 KB |
Output is correct |
2 |
Correct |
7 ms |
4360 KB |
Output is correct |
3 |
Correct |
7 ms |
4384 KB |
Output is correct |
4 |
Correct |
7 ms |
4416 KB |
Output is correct |
5 |
Correct |
6 ms |
4416 KB |
Output is correct |
6 |
Correct |
7 ms |
4416 KB |
Output is correct |
7 |
Correct |
7 ms |
4416 KB |
Output is correct |
8 |
Correct |
7 ms |
4416 KB |
Output is correct |
9 |
Correct |
9 ms |
4416 KB |
Output is correct |
10 |
Correct |
7 ms |
4416 KB |
Output is correct |
11 |
Correct |
7 ms |
4416 KB |
Output is correct |
12 |
Correct |
7 ms |
4416 KB |
Output is correct |
13 |
Correct |
6 ms |
4432 KB |
Output is correct |
14 |
Correct |
8 ms |
4476 KB |
Output is correct |
15 |
Correct |
7 ms |
4476 KB |
Output is correct |
16 |
Correct |
6 ms |
4476 KB |
Output is correct |
17 |
Correct |
7 ms |
4476 KB |
Output is correct |
18 |
Correct |
6 ms |
4476 KB |
Output is correct |
19 |
Correct |
6 ms |
4476 KB |
Output is correct |
20 |
Correct |
7 ms |
4476 KB |
Output is correct |
21 |
Correct |
362 ms |
4476 KB |
Output is correct |
22 |
Correct |
362 ms |
4604 KB |
Output is correct |
23 |
Correct |
302 ms |
4604 KB |
Output is correct |
24 |
Correct |
391 ms |
4668 KB |
Output is correct |
25 |
Correct |
322 ms |
4668 KB |
Output is correct |
26 |
Correct |
651 ms |
4744 KB |
Output is correct |
27 |
Correct |
653 ms |
4776 KB |
Output is correct |
28 |
Correct |
662 ms |
4852 KB |
Output is correct |
29 |
Correct |
684 ms |
4852 KB |
Output is correct |
30 |
Correct |
9 ms |
4852 KB |
Output is correct |
31 |
Correct |
10 ms |
4852 KB |
Output is correct |
32 |
Correct |
9 ms |
4852 KB |
Output is correct |
33 |
Correct |
9 ms |
4852 KB |
Output is correct |
34 |
Correct |
9 ms |
4852 KB |
Output is correct |
35 |
Correct |
11 ms |
4852 KB |
Output is correct |
36 |
Correct |
11 ms |
4852 KB |
Output is correct |
37 |
Correct |
10 ms |
4852 KB |
Output is correct |
38 |
Correct |
11 ms |
4852 KB |
Output is correct |
39 |
Correct |
6 ms |
4852 KB |
Output is correct |
40 |
Correct |
5 ms |
4852 KB |
Output is correct |
41 |
Correct |
5 ms |
4852 KB |
Output is correct |
42 |
Correct |
5 ms |
4852 KB |
Output is correct |
43 |
Correct |
6 ms |
4852 KB |
Output is correct |
44 |
Correct |
9 ms |
4852 KB |
Output is correct |
45 |
Correct |
8 ms |
4852 KB |
Output is correct |
46 |
Correct |
8 ms |
4852 KB |
Output is correct |
47 |
Correct |
9 ms |
4852 KB |
Output is correct |
48 |
Correct |
8 ms |
4852 KB |
Output is correct |
49 |
Correct |
5 ms |
4852 KB |
Output is correct |
50 |
Correct |
5 ms |
4852 KB |
Output is correct |
51 |
Correct |
5 ms |
4852 KB |
Output is correct |
52 |
Correct |
5 ms |
4852 KB |
Output is correct |
53 |
Correct |
5 ms |
4852 KB |
Output is correct |
54 |
Correct |
5 ms |
4852 KB |
Output is correct |
55 |
Correct |
4 ms |
4852 KB |
Output is correct |
56 |
Correct |
4 ms |
4852 KB |
Output is correct |
57 |
Correct |
4 ms |
4852 KB |
Output is correct |
58 |
Correct |
4 ms |
4852 KB |
Output is correct |
59 |
Correct |
375 ms |
4940 KB |
Output is correct |
60 |
Correct |
348 ms |
4940 KB |
Output is correct |
61 |
Correct |
399 ms |
5096 KB |
Output is correct |
62 |
Correct |
406 ms |
5096 KB |
Output is correct |
63 |
Correct |
443 ms |
5096 KB |
Output is correct |
64 |
Correct |
816 ms |
5124 KB |
Output is correct |
65 |
Correct |
877 ms |
5124 KB |
Output is correct |
66 |
Correct |
813 ms |
5164 KB |
Output is correct |
67 |
Correct |
762 ms |
5256 KB |
Output is correct |
68 |
Correct |
746 ms |
5256 KB |
Output is correct |
69 |
Correct |
304 ms |
5256 KB |
Output is correct |
70 |
Correct |
297 ms |
5256 KB |
Output is correct |
71 |
Correct |
309 ms |
5256 KB |
Output is correct |
72 |
Correct |
350 ms |
5256 KB |
Output is correct |
73 |
Correct |
342 ms |
5256 KB |
Output is correct |
74 |
Correct |
91 ms |
5256 KB |
Output is correct |
75 |
Correct |
74 ms |
5256 KB |
Output is correct |
76 |
Correct |
78 ms |
5256 KB |
Output is correct |
77 |
Correct |
76 ms |
5256 KB |
Output is correct |
78 |
Correct |
78 ms |
5256 KB |
Output is correct |