# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
74695 |
2018-09-06T14:49:06 Z |
Vardanyan |
Boat (APIO16_boat) |
C++14 |
|
1541 ms |
525312 KB |
//#pragma GCC optimize "-O3"
#include <bits/stdc++.h>
using namespace std;
int a[505],b[505];
const int MOD = 1000*1000*1000+7;
struct node{
node *l;
node *r;
int val;
node():l(NULL),r(NULL),val(0){}
};
void update(node *v, int s,int e,int l,int r,int val){
if(l>r) return;
if(s == l && e == r){
v->val += val;
return;
}
int m = (s+e)/2;
if(v->l == NULL){
v->l = new node();
v->r = new node();
}
update(v->l,s,m,l,min(m,r),val);
update(v->r,m+1,e,max(l,m+1),r,val);
v->val = (v->l->val+v->r->val)%MOD;
}
int query(node *v, int s,int e,int l,int r){
if(v == NULL) return 0;
if(l>r) return 0;
if(s == l && e == r) return v->val;
int m = (s+e)/2;
return (query(v->l,s,m,l,min(m,r))+query(v->r,m+1,e,max(l,m+1),r))%MOD;
}
int main(){
int n;
scanf("%d",&n);
for(int i = 1;i<=n;i++){
scanf("%d%d",&a[i],&b[i]);
}
node* root = new node();;
for(int i = 1;i<=n;i++){
vector<int> v;
int p = 0;
for(int j = a[i];j<=b[i];j++){
int x = query(root,1,1000*1000*1000,1,j-1);
v.push_back(x);
}
for(int j = a[i];j<=b[i];j++){
update(root,1,1000*1000*1000,j,j,v[p]+1);
p++;
}
}
cout<<query(root,1,1000*1000*1000,1,1000*1000*1000)<<endl;
return 0;
}
Compilation message
boat.cpp: In function 'int main()':
boat.cpp:36:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&n);
~~~~~^~~~~~~~~
boat.cpp:38:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d",&a[i],&b[i]);
~~~~~^~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1016 KB |
Output is correct |
2 |
Correct |
4 ms |
1024 KB |
Output is correct |
3 |
Correct |
4 ms |
1128 KB |
Output is correct |
4 |
Correct |
4 ms |
1156 KB |
Output is correct |
5 |
Correct |
4 ms |
1180 KB |
Output is correct |
6 |
Correct |
3 ms |
1256 KB |
Output is correct |
7 |
Correct |
4 ms |
1400 KB |
Output is correct |
8 |
Correct |
3 ms |
1400 KB |
Output is correct |
9 |
Correct |
4 ms |
1400 KB |
Output is correct |
10 |
Correct |
3 ms |
1456 KB |
Output is correct |
11 |
Correct |
4 ms |
1456 KB |
Output is correct |
12 |
Correct |
4 ms |
1468 KB |
Output is correct |
13 |
Correct |
3 ms |
1480 KB |
Output is correct |
14 |
Correct |
4 ms |
1496 KB |
Output is correct |
15 |
Correct |
4 ms |
1508 KB |
Output is correct |
16 |
Incorrect |
3 ms |
1508 KB |
Output isn't correct |
17 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1016 KB |
Output is correct |
2 |
Correct |
4 ms |
1024 KB |
Output is correct |
3 |
Correct |
4 ms |
1128 KB |
Output is correct |
4 |
Correct |
4 ms |
1156 KB |
Output is correct |
5 |
Correct |
4 ms |
1180 KB |
Output is correct |
6 |
Correct |
3 ms |
1256 KB |
Output is correct |
7 |
Correct |
4 ms |
1400 KB |
Output is correct |
8 |
Correct |
3 ms |
1400 KB |
Output is correct |
9 |
Correct |
4 ms |
1400 KB |
Output is correct |
10 |
Correct |
3 ms |
1456 KB |
Output is correct |
11 |
Correct |
4 ms |
1456 KB |
Output is correct |
12 |
Correct |
4 ms |
1468 KB |
Output is correct |
13 |
Correct |
3 ms |
1480 KB |
Output is correct |
14 |
Correct |
4 ms |
1496 KB |
Output is correct |
15 |
Correct |
4 ms |
1508 KB |
Output is correct |
16 |
Incorrect |
3 ms |
1508 KB |
Output isn't correct |
17 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1541 ms |
525312 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1016 KB |
Output is correct |
2 |
Correct |
4 ms |
1024 KB |
Output is correct |
3 |
Correct |
4 ms |
1128 KB |
Output is correct |
4 |
Correct |
4 ms |
1156 KB |
Output is correct |
5 |
Correct |
4 ms |
1180 KB |
Output is correct |
6 |
Correct |
3 ms |
1256 KB |
Output is correct |
7 |
Correct |
4 ms |
1400 KB |
Output is correct |
8 |
Correct |
3 ms |
1400 KB |
Output is correct |
9 |
Correct |
4 ms |
1400 KB |
Output is correct |
10 |
Correct |
3 ms |
1456 KB |
Output is correct |
11 |
Correct |
4 ms |
1456 KB |
Output is correct |
12 |
Correct |
4 ms |
1468 KB |
Output is correct |
13 |
Correct |
3 ms |
1480 KB |
Output is correct |
14 |
Correct |
4 ms |
1496 KB |
Output is correct |
15 |
Correct |
4 ms |
1508 KB |
Output is correct |
16 |
Incorrect |
3 ms |
1508 KB |
Output isn't correct |
17 |
Halted |
0 ms |
0 KB |
- |