Submission #74698

# Submission time Handle Problem Language Result Execution time Memory
74698 2018-09-06T14:51:42 Z Vardanyan Boat (APIO16_boat) C++14
31 / 100
1154 ms 525312 KB
//#pragma GCC optimize "-O3"
#include <bits/stdc++.h>
using namespace std;
int a[505],b[505];
const long long MOD = 1000*1000*1000+7;
struct node{
    node *l;
    node *r;
    long long val;
    node():l(NULL),r(NULL),val(0){}
};
void update(node *v, int s,int e,int l,int r,long long 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;
}
long long 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<long long> v;
        int p = 0;
        for(int j = a[i];j<=b[i];j++){
            long long x = query(root,1,1000*1000*1000,1,j-1);
            x%=MOD;
            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))%MOD<<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 5 ms 1016 KB Output is correct
2 Correct 4 ms 1152 KB Output is correct
3 Correct 4 ms 1152 KB Output is correct
4 Correct 4 ms 1256 KB Output is correct
5 Correct 4 ms 1300 KB Output is correct
6 Correct 3 ms 1372 KB Output is correct
7 Correct 4 ms 1372 KB Output is correct
8 Correct 4 ms 1380 KB Output is correct
9 Correct 3 ms 1408 KB Output is correct
10 Correct 4 ms 1420 KB Output is correct
11 Correct 4 ms 1432 KB Output is correct
12 Correct 4 ms 1444 KB Output is correct
13 Correct 3 ms 1456 KB Output is correct
14 Correct 4 ms 1468 KB Output is correct
15 Correct 3 ms 1480 KB Output is correct
16 Correct 3 ms 1480 KB Output is correct
17 Correct 3 ms 1480 KB Output is correct
18 Correct 4 ms 1480 KB Output is correct
19 Correct 3 ms 1480 KB Output is correct
20 Correct 3 ms 1480 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1016 KB Output is correct
2 Correct 4 ms 1152 KB Output is correct
3 Correct 4 ms 1152 KB Output is correct
4 Correct 4 ms 1256 KB Output is correct
5 Correct 4 ms 1300 KB Output is correct
6 Correct 3 ms 1372 KB Output is correct
7 Correct 4 ms 1372 KB Output is correct
8 Correct 4 ms 1380 KB Output is correct
9 Correct 3 ms 1408 KB Output is correct
10 Correct 4 ms 1420 KB Output is correct
11 Correct 4 ms 1432 KB Output is correct
12 Correct 4 ms 1444 KB Output is correct
13 Correct 3 ms 1456 KB Output is correct
14 Correct 4 ms 1468 KB Output is correct
15 Correct 3 ms 1480 KB Output is correct
16 Correct 3 ms 1480 KB Output is correct
17 Correct 3 ms 1480 KB Output is correct
18 Correct 4 ms 1480 KB Output is correct
19 Correct 3 ms 1480 KB Output is correct
20 Correct 3 ms 1480 KB Output is correct
21 Correct 641 ms 1480 KB Output is correct
22 Correct 626 ms 1560 KB Output is correct
23 Correct 601 ms 1560 KB Output is correct
24 Correct 645 ms 1560 KB Output is correct
25 Correct 670 ms 1560 KB Output is correct
26 Correct 704 ms 1560 KB Output is correct
27 Correct 708 ms 1560 KB Output is correct
28 Correct 700 ms 1560 KB Output is correct
29 Correct 753 ms 1560 KB Output is correct
30 Correct 750 ms 63140 KB Output is correct
31 Correct 717 ms 63140 KB Output is correct
32 Correct 717 ms 63380 KB Output is correct
33 Correct 725 ms 63380 KB Output is correct
34 Correct 696 ms 63380 KB Output is correct
35 Correct 711 ms 63380 KB Output is correct
36 Correct 709 ms 63380 KB Output is correct
37 Correct 699 ms 63380 KB Output is correct
38 Correct 693 ms 63380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1154 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 5 ms 1016 KB Output is correct
2 Correct 4 ms 1152 KB Output is correct
3 Correct 4 ms 1152 KB Output is correct
4 Correct 4 ms 1256 KB Output is correct
5 Correct 4 ms 1300 KB Output is correct
6 Correct 3 ms 1372 KB Output is correct
7 Correct 4 ms 1372 KB Output is correct
8 Correct 4 ms 1380 KB Output is correct
9 Correct 3 ms 1408 KB Output is correct
10 Correct 4 ms 1420 KB Output is correct
11 Correct 4 ms 1432 KB Output is correct
12 Correct 4 ms 1444 KB Output is correct
13 Correct 3 ms 1456 KB Output is correct
14 Correct 4 ms 1468 KB Output is correct
15 Correct 3 ms 1480 KB Output is correct
16 Correct 3 ms 1480 KB Output is correct
17 Correct 3 ms 1480 KB Output is correct
18 Correct 4 ms 1480 KB Output is correct
19 Correct 3 ms 1480 KB Output is correct
20 Correct 3 ms 1480 KB Output is correct
21 Correct 641 ms 1480 KB Output is correct
22 Correct 626 ms 1560 KB Output is correct
23 Correct 601 ms 1560 KB Output is correct
24 Correct 645 ms 1560 KB Output is correct
25 Correct 670 ms 1560 KB Output is correct
26 Correct 704 ms 1560 KB Output is correct
27 Correct 708 ms 1560 KB Output is correct
28 Correct 700 ms 1560 KB Output is correct
29 Correct 753 ms 1560 KB Output is correct
30 Correct 750 ms 63140 KB Output is correct
31 Correct 717 ms 63140 KB Output is correct
32 Correct 717 ms 63380 KB Output is correct
33 Correct 725 ms 63380 KB Output is correct
34 Correct 696 ms 63380 KB Output is correct
35 Correct 711 ms 63380 KB Output is correct
36 Correct 709 ms 63380 KB Output is correct
37 Correct 699 ms 63380 KB Output is correct
38 Correct 693 ms 63380 KB Output is correct
39 Runtime error 1154 ms 525312 KB Execution killed with signal 9 (could be triggered by violating memory limits)
40 Halted 0 ms 0 KB -