답안 #673182

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
673182 2022-12-19T21:48:35 Z beedle Bali Sculptures (APIO15_sculpture) C++17
71 / 100
52 ms 360 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;  
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 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 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 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 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 1 ms 212 KB Output is correct
27 Correct 1 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
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 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 1 ms 212 KB Output is correct
16 Correct 0 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 212 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 7 ms 212 KB Output is correct
33 Correct 8 ms 212 KB Output is correct
34 Correct 7 ms 212 KB Output is correct
35 Correct 7 ms 212 KB Output is correct
36 Correct 7 ms 212 KB Output is correct
# 결과 실행 시간 메모리 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 1 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 2 ms 212 KB Output is correct
16 Correct 4 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 8 ms 328 KB Output is correct
21 Correct 8 ms 212 KB Output is correct
22 Correct 7 ms 212 KB Output is correct
23 Correct 7 ms 212 KB Output is correct
24 Correct 8 ms 212 KB Output is correct
25 Correct 14 ms 336 KB Output is correct
26 Correct 23 ms 340 KB Output is correct
27 Correct 36 ms 340 KB Output is correct
28 Correct 46 ms 340 KB Output is correct
29 Correct 45 ms 340 KB Output is correct
30 Correct 52 ms 340 KB Output is correct
31 Correct 46 ms 340 KB Output is correct
32 Correct 45 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 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 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 0 ms 212 KB Output is correct
15 Correct 1 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 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 340 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
37 Correct 1 ms 212 KB Output is correct
38 Correct 2 ms 212 KB Output is correct
39 Correct 4 ms 212 KB Output is correct
40 Correct 5 ms 324 KB Output is correct
41 Correct 7 ms 328 KB Output is correct
42 Correct 7 ms 212 KB Output is correct
43 Correct 7 ms 324 KB Output is correct
44 Correct 8 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 7 ms 212 KB Output is correct
48 Correct 13 ms 212 KB Output is correct
49 Correct 23 ms 344 KB Output is correct
50 Correct 42 ms 352 KB Output is correct
51 Correct 46 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 344 KB Output is correct
58 Correct 21 ms 340 KB Output is correct
59 Correct 26 ms 356 KB Output is correct
60 Correct 26 ms 360 KB Output is correct
61 Correct 25 ms 356 KB Output is correct
62 Correct 28 ms 340 KB Output is correct
63 Correct 28 ms 340 KB Output is correct
64 Correct 36 ms 340 KB Output is correct
65 Correct 5 ms 212 KB Output is correct
66 Correct 8 ms 212 KB Output is correct
67 Correct 13 ms 340 KB Output is correct
68 Correct 20 ms 340 KB Output is correct
69 Correct 26 ms 340 KB Output is correct
70 Correct 25 ms 340 KB Output is correct
71 Correct 27 ms 340 KB Output is correct
72 Correct 28 ms 340 KB Output is correct
73 Correct 28 ms 352 KB Output is correct
74 Correct 28 ms 340 KB Output is correct
# 결과 실행 시간 메모리 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 1 ms 312 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 2 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 304 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 7 ms 324 KB Output is correct
31 Correct 8 ms 212 KB Output is correct
32 Correct 7 ms 212 KB Output is correct
33 Correct 7 ms 212 KB Output is correct
34 Correct 8 ms 212 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 45 ms 340 KB Output is correct
39 Correct 45 ms 340 KB Output is correct
40 Correct 47 ms 340 KB Output is correct
41 Correct 44 ms 340 KB Output is correct
42 Correct 45 ms 340 KB Output is correct
43 Correct 5 ms 212 KB Output is correct
44 Correct 15 ms 340 KB Output is correct
45 Correct 20 ms 348 KB Output is correct
46 Correct 25 ms 352 KB Output is correct
47 Correct 25 ms 340 KB Output is correct
48 Correct 25 ms 340 KB Output is correct
49 Correct 29 ms 356 KB Output is correct
50 Correct 28 ms 340 KB Output is correct
51 Incorrect 2 ms 340 KB Output isn't correct
52 Halted 0 ms 0 KB -