Submission #397847

# Submission time Handle Problem Language Result Execution time Memory
397847 2021-05-03T09:33:10 Z juggernaut Bali Sculptures (APIO15_sculpture) C++14
71 / 100
1000 ms 748 KB
#include<bits/stdc++.h>
#define fr first
#define sc second
using namespace std;
void usaco(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
typedef long long ll;
#define USING_ORDERED_SET 0
#if USING_ORDERED_SET
#include<bits/extc++.h>
using namespace __gnu_pbds;
template<class T>using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
#endif
template<class T>void umax(T &a,T b){if(a<b)a=b;}
template<class T>void umin(T &a,T b){if(b<a)a=b;}
#ifdef IOI2021SG
    #define printl(args...)printf(args)
#else
    #define printl(args...)((void)0)
#endif
int n,l,r,a[2005];
int main(){
    scanf("%d%d%d",&n,&l,&r);
    for(int i=0;i<n;i++)scanf("%d",&a[i]);
    ll ans=0;
    for(int bit=45;bit>=0;bit--){
        vector<bitset<2005>>dp(n+5);
        dp[0]=1;
        for(int j=1;j<=n;j++){
            ll sum=0;
            for(int k=j-1;k>=0;k--){
                sum+=a[k];
                if(((sum>>(bit+1))|ans)==ans&&!((sum>>bit)&1))dp[j]|=dp[k]<<1;
            }
        }
        bool flag=false;
        for(int i=l;i<=r;i++)flag|=dp[n][i];
        ans<<=1;
        ans|=(!flag);
    }
    printf("%lld",ans);
}

Compilation message

sculpture.cpp: In function 'void usaco(std::string)':
sculpture.cpp:5:29: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
    5 | void usaco(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sculpture.cpp:5:66: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
    5 | void usaco(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                                                           ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sculpture.cpp: In function 'int main()':
sculpture.cpp:22:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   22 |     scanf("%d%d%d",&n,&l,&r);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
sculpture.cpp:23:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   23 |     for(int i=0;i<n;i++)scanf("%d",&a[i]);
      |                         ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 2 ms 296 KB Output is correct
9 Correct 2 ms 204 KB Output is correct
10 Correct 2 ms 204 KB Output is correct
11 Correct 2 ms 204 KB Output is correct
12 Correct 2 ms 296 KB Output is correct
13 Correct 2 ms 204 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 2 ms 296 KB Output is correct
22 Correct 2 ms 204 KB Output is correct
23 Correct 2 ms 204 KB Output is correct
24 Correct 2 ms 204 KB Output is correct
25 Correct 2 ms 204 KB Output is correct
26 Correct 2 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 300 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 1 ms 296 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 1 ms 204 KB Output is correct
36 Correct 2 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 2 ms 204 KB Output is correct
7 Correct 2 ms 204 KB Output is correct
8 Correct 2 ms 204 KB Output is correct
9 Correct 2 ms 204 KB Output is correct
10 Correct 2 ms 304 KB Output is correct
11 Correct 2 ms 204 KB Output is correct
12 Correct 2 ms 204 KB Output is correct
13 Correct 2 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 2 ms 304 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 2 ms 312 KB Output is correct
22 Correct 2 ms 204 KB Output is correct
23 Correct 2 ms 204 KB Output is correct
24 Correct 2 ms 204 KB Output is correct
25 Correct 2 ms 304 KB Output is correct
26 Correct 2 ms 204 KB Output is correct
27 Correct 2 ms 204 KB Output is correct
28 Correct 2 ms 204 KB Output is correct
29 Correct 4 ms 204 KB Output is correct
30 Correct 4 ms 204 KB Output is correct
31 Correct 6 ms 204 KB Output is correct
32 Correct 6 ms 204 KB Output is correct
33 Correct 7 ms 204 KB Output is correct
34 Correct 6 ms 208 KB Output is correct
35 Correct 8 ms 320 KB Output is correct
36 Correct 6 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 2 ms 204 KB Output is correct
9 Correct 2 ms 204 KB Output is correct
10 Correct 2 ms 208 KB Output is correct
11 Correct 2 ms 204 KB Output is correct
12 Correct 2 ms 204 KB Output is correct
13 Correct 2 ms 204 KB Output is correct
14 Correct 2 ms 204 KB Output is correct
15 Correct 2 ms 300 KB Output is correct
16 Correct 4 ms 204 KB Output is correct
17 Correct 4 ms 204 KB Output is correct
18 Correct 8 ms 204 KB Output is correct
19 Correct 6 ms 312 KB Output is correct
20 Correct 6 ms 204 KB Output is correct
21 Correct 6 ms 204 KB Output is correct
22 Correct 6 ms 204 KB Output is correct
23 Correct 6 ms 204 KB Output is correct
24 Correct 6 ms 204 KB Output is correct
25 Correct 9 ms 204 KB Output is correct
26 Correct 13 ms 316 KB Output is correct
27 Correct 17 ms 296 KB Output is correct
28 Correct 20 ms 332 KB Output is correct
29 Correct 20 ms 324 KB Output is correct
30 Correct 26 ms 204 KB Output is correct
31 Correct 20 ms 328 KB Output is correct
32 Correct 20 ms 328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 2 ms 208 KB Output is correct
9 Correct 2 ms 208 KB Output is correct
10 Correct 2 ms 304 KB Output is correct
11 Correct 2 ms 208 KB Output is correct
12 Correct 2 ms 204 KB Output is correct
13 Correct 2 ms 308 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 208 KB Output is correct
17 Correct 1 ms 208 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 2 ms 204 KB Output is correct
22 Correct 2 ms 208 KB Output is correct
23 Correct 2 ms 204 KB Output is correct
24 Correct 2 ms 332 KB Output is correct
25 Correct 2 ms 204 KB Output is correct
26 Correct 2 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 1 ms 204 KB Output is correct
34 Correct 2 ms 332 KB Output is correct
35 Correct 2 ms 204 KB Output is correct
36 Correct 2 ms 204 KB Output is correct
37 Correct 2 ms 204 KB Output is correct
38 Correct 2 ms 204 KB Output is correct
39 Correct 4 ms 204 KB Output is correct
40 Correct 5 ms 304 KB Output is correct
41 Correct 6 ms 204 KB Output is correct
42 Correct 7 ms 204 KB Output is correct
43 Correct 6 ms 204 KB Output is correct
44 Correct 6 ms 204 KB Output is correct
45 Correct 6 ms 204 KB Output is correct
46 Correct 6 ms 204 KB Output is correct
47 Correct 6 ms 204 KB Output is correct
48 Correct 9 ms 204 KB Output is correct
49 Correct 12 ms 204 KB Output is correct
50 Correct 18 ms 204 KB Output is correct
51 Correct 22 ms 204 KB Output is correct
52 Correct 29 ms 204 KB Output is correct
53 Correct 27 ms 204 KB Output is correct
54 Correct 21 ms 332 KB Output is correct
55 Correct 19 ms 332 KB Output is correct
56 Correct 3 ms 204 KB Output is correct
57 Correct 5 ms 204 KB Output is correct
58 Correct 6 ms 204 KB Output is correct
59 Correct 8 ms 204 KB Output is correct
60 Correct 7 ms 328 KB Output is correct
61 Correct 7 ms 328 KB Output is correct
62 Correct 11 ms 204 KB Output is correct
63 Correct 13 ms 324 KB Output is correct
64 Correct 18 ms 332 KB Output is correct
65 Correct 3 ms 204 KB Output is correct
66 Correct 4 ms 204 KB Output is correct
67 Correct 6 ms 204 KB Output is correct
68 Correct 7 ms 324 KB Output is correct
69 Correct 10 ms 324 KB Output is correct
70 Correct 7 ms 332 KB Output is correct
71 Correct 8 ms 204 KB Output is correct
72 Correct 10 ms 204 KB Output is correct
73 Correct 9 ms 204 KB Output is correct
74 Correct 9 ms 328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 2 ms 300 KB Output is correct
8 Correct 2 ms 300 KB Output is correct
9 Correct 2 ms 204 KB Output is correct
10 Correct 2 ms 208 KB Output is correct
11 Correct 2 ms 296 KB Output is correct
12 Correct 2 ms 204 KB Output is correct
13 Correct 2 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 304 KB Output is correct
20 Correct 1 ms 296 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 2 ms 204 KB Output is correct
23 Correct 2 ms 204 KB Output is correct
24 Correct 2 ms 208 KB Output is correct
25 Correct 2 ms 308 KB Output is correct
26 Correct 4 ms 204 KB Output is correct
27 Correct 5 ms 204 KB Output is correct
28 Correct 6 ms 204 KB Output is correct
29 Correct 6 ms 308 KB Output is correct
30 Correct 6 ms 204 KB Output is correct
31 Correct 6 ms 204 KB Output is correct
32 Correct 6 ms 208 KB Output is correct
33 Correct 6 ms 312 KB Output is correct
34 Correct 6 ms 308 KB Output is correct
35 Correct 9 ms 204 KB Output is correct
36 Correct 12 ms 204 KB Output is correct
37 Correct 17 ms 204 KB Output is correct
38 Correct 20 ms 332 KB Output is correct
39 Correct 19 ms 328 KB Output is correct
40 Correct 22 ms 328 KB Output is correct
41 Correct 19 ms 328 KB Output is correct
42 Correct 20 ms 332 KB Output is correct
43 Correct 3 ms 204 KB Output is correct
44 Correct 5 ms 204 KB Output is correct
45 Correct 7 ms 204 KB Output is correct
46 Correct 8 ms 296 KB Output is correct
47 Correct 7 ms 332 KB Output is correct
48 Correct 7 ms 332 KB Output is correct
49 Correct 12 ms 332 KB Output is correct
50 Correct 9 ms 204 KB Output is correct
51 Correct 12 ms 324 KB Output is correct
52 Correct 177 ms 460 KB Output is correct
53 Correct 282 ms 472 KB Output is correct
54 Correct 490 ms 564 KB Output is correct
55 Correct 483 ms 540 KB Output is correct
56 Execution timed out 1085 ms 748 KB Time limit exceeded
57 Halted 0 ms 0 KB -