Submission #673179

# Submission time Handle Problem Language Result Execution time Memory
673179 2022-12-19T21:45:53 Z beedle Bali Sculptures (APIO15_sculpture) C++17
71 / 100
52 ms 468 KB
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <set>
#include <iterator>
#include <stack>
#include <map>
#include <math.h>
#include <bitset>
#include <deque>
#include <string>
#include <tuple>
#include <queue>
#include <numeric>
#include <complex>
#include <assert.h>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define ld long long double
#define rep(i, a, b) for (long long i = a; i <= b; i++)
#define mod 1000000007ll
#define INF 1e18
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define all(x) (x).begin (), (x).end ()
#define sz(x) (ll) (x).size ()
#define reunique(v) v.resize(std::unique(v.begin(), v.end()) - v.begin())
#define rank rnk
#define log lg
#define fast                                                                  \
    ios_base::sync_with_stdio (false);                                        \
    cin.tie (NULL);                                                           \
    cout.tie (NULL)
 
using namespace std;

signed main()
{
    fast;

    // freopen("curling.in","r",stdin);
    // freopen("curling.out","w",stdout);

    ll n,a,b;
    cin>>n>>a>>b;

    ll arr[n+1];
    rep(i,1,n)
    cin>>arr[i];

    ll s[n+1];
    s[0]=0;
    rep(i,1,n)
    s[i]=s[i-1]+arr[i];

    ll ans=0;

    for(ll idx=62;idx>=0;--idx)
    {
        ans+=(1ll<<idx)-1;
        
        vector<vector<int>> adj(n+1);
        rep(i,0,n)
        rep(j,i+1,n)
        if(((s[j]-s[i])&(~ans))==0)
        adj[i].pb(j);

        bool ok=false;
        if(n<=100)
        {
            vector <vector<bool>> ispath(n+1,vector<bool>(n+1));
            ispath[0][0]=true;

            rep(i,0,n)
            for(auto j:adj[i])
            rep(cnt,0,n)
            if(ispath[i][cnt])
            ispath[j][cnt+1]=true;

            rep(i,a,b)
            if(ispath[n][i])
            ok=true;
        }
        else
        {
            queue <ll> q;
            vector <ll> d(n+1,INF);
            q.push(0);
            d[0]=0;

            while(!q.empty())
            {
                auto v=q.front();
                q.pop();
                for(auto u:adj[v])
                if(d[u]!=INF)
                {
                    d[u]=1+d[v];
                    q.push(v);
                }
            }

            if(d[n]<=b)
            ok=true;
        }

        if(ok)
        ans-=(1ll<<idx)-1;
        else
        ans+=1;
    }

    cout<<ans;

    return 0;  
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 2 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 356 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 2 ms 212 KB Output is correct
29 Correct 4 ms 212 KB Output is correct
30 Correct 5 ms 212 KB Output is correct
31 Correct 8 ms 212 KB Output is correct
32 Correct 8 ms 212 KB Output is correct
33 Correct 8 ms 212 KB Output is correct
34 Correct 9 ms 332 KB Output is correct
35 Correct 8 ms 212 KB Output is correct
36 Correct 8 ms 324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 2 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 2 ms 212 KB Output is correct
16 Correct 5 ms 212 KB Output is correct
17 Correct 5 ms 212 KB Output is correct
18 Correct 8 ms 212 KB Output is correct
19 Correct 7 ms 212 KB Output is correct
20 Correct 9 ms 324 KB Output is correct
21 Correct 8 ms 212 KB Output is correct
22 Correct 7 ms 212 KB Output is correct
23 Correct 8 ms 332 KB Output is correct
24 Correct 7 ms 212 KB Output is correct
25 Correct 15 ms 336 KB Output is correct
26 Correct 26 ms 212 KB Output is correct
27 Correct 36 ms 340 KB Output is correct
28 Correct 48 ms 340 KB Output is correct
29 Correct 48 ms 340 KB Output is correct
30 Correct 47 ms 340 KB Output is correct
31 Correct 52 ms 340 KB Output is correct
32 Correct 47 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 2 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 216 KB Output is correct
20 Correct 1 ms 216 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 224 KB Output is correct
23 Correct 1 ms 316 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 272 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 1 ms 216 KB Output is correct
29 Correct 1 ms 216 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 2 ms 212 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 216 KB Output is correct
38 Correct 2 ms 216 KB Output is correct
39 Correct 4 ms 216 KB Output is correct
40 Correct 5 ms 328 KB Output is correct
41 Correct 7 ms 212 KB Output is correct
42 Correct 7 ms 212 KB Output is correct
43 Correct 8 ms 328 KB Output is correct
44 Correct 7 ms 212 KB Output is correct
45 Correct 7 ms 212 KB Output is correct
46 Correct 7 ms 212 KB Output is correct
47 Correct 8 ms 212 KB Output is correct
48 Correct 14 ms 332 KB Output is correct
49 Correct 27 ms 340 KB Output is correct
50 Correct 36 ms 340 KB Output is correct
51 Correct 48 ms 340 KB Output is correct
52 Correct 44 ms 340 KB Output is correct
53 Correct 46 ms 340 KB Output is correct
54 Correct 45 ms 340 KB Output is correct
55 Correct 46 ms 340 KB Output is correct
56 Correct 5 ms 212 KB Output is correct
57 Correct 13 ms 340 KB Output is correct
58 Correct 24 ms 344 KB Output is correct
59 Correct 26 ms 340 KB Output is correct
60 Correct 29 ms 340 KB Output is correct
61 Correct 29 ms 340 KB Output is correct
62 Correct 28 ms 340 KB Output is correct
63 Correct 27 ms 340 KB Output is correct
64 Correct 36 ms 352 KB Output is correct
65 Correct 5 ms 332 KB Output is correct
66 Correct 10 ms 340 KB Output is correct
67 Correct 17 ms 468 KB Output is correct
68 Correct 21 ms 340 KB Output is correct
69 Correct 26 ms 340 KB Output is correct
70 Correct 24 ms 340 KB Output is correct
71 Correct 27 ms 348 KB Output is correct
72 Correct 31 ms 344 KB Output is correct
73 Correct 31 ms 360 KB Output is correct
74 Correct 30 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 216 KB Output is correct
2 Correct 0 ms 216 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 216 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 2 ms 212 KB Output is correct
26 Correct 4 ms 316 KB Output is correct
27 Correct 5 ms 212 KB Output is correct
28 Correct 8 ms 212 KB Output is correct
29 Correct 7 ms 212 KB Output is correct
30 Correct 8 ms 212 KB Output is correct
31 Correct 8 ms 324 KB Output is correct
32 Correct 9 ms 212 KB Output is correct
33 Correct 8 ms 212 KB Output is correct
34 Correct 10 ms 328 KB Output is correct
35 Correct 14 ms 340 KB Output is correct
36 Correct 23 ms 344 KB Output is correct
37 Correct 35 ms 340 KB Output is correct
38 Correct 47 ms 340 KB Output is correct
39 Correct 51 ms 340 KB Output is correct
40 Correct 50 ms 340 KB Output is correct
41 Correct 47 ms 356 KB Output is correct
42 Correct 50 ms 340 KB Output is correct
43 Correct 6 ms 212 KB Output is correct
44 Correct 15 ms 344 KB Output is correct
45 Correct 20 ms 352 KB Output is correct
46 Correct 26 ms 356 KB Output is correct
47 Correct 25 ms 340 KB Output is correct
48 Correct 26 ms 340 KB Output is correct
49 Correct 28 ms 356 KB Output is correct
50 Correct 28 ms 340 KB Output is correct
51 Incorrect 3 ms 348 KB Output isn't correct
52 Halted 0 ms 0 KB -