Submission #735329

# Submission time Handle Problem Language Result Execution time Memory
735329 2023-05-04T02:26:37 Z ReLice Bali Sculptures (APIO15_sculpture) C++14
71 / 100
1000 ms 3632 KB
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define endl "\n"
#define fr first
#define sc second
#define sz size()
#define bc back()
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>
void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}*/
void start(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
const ll inf=1e9+7;
const ll mod=1e9+7;
const ll N=2e3+7;
ll pref[N],n,l,r;
vector<vector<ll> > g(N);
ll vis[N];
ll d[N];
bool check(ll val){
    deque <pair<ll,ll>> q;
    q.pb({0,1});
    for(ll i=1;i<=n+1;i++) d[i]=inf;
    d[1]=0;
    while(!q.empty()){
        ll x=q.front().sc;
        q.pop_front();
        for(auto i : g[x]){
            if((pref[i]-pref[x-1]) & (1ll<<val)) continue;
            if(d[x]+1<d[i+1]){
                d[i+1]=d[x]+1;
                q.pb({d[i+1],i+1});
            }
        }
    }
    ll l1=d[n+1],r1;
    q.pb({0,1});
    for(ll i=1;i<=n+1;i++) d[i]=inf;
    d[1]=0;
    while(!q.empty()){
        ll x=q.front().sc;
        q.pop_front();
        for(auto i : g[x]){
            if((pref[i]-pref[x-1]) & (1ll<<val)) continue;
            if(d[x]-1<d[i+1]){
                d[i+1]=d[x]-1;
                q.push_front({d[i+1],i+1});
            }
        }
    }
    r1=-d[n+1];
    if(r1<l || l1>r || l1==inf || r1==inf) return false;
    else return true;
}
void ers(ll val){
    for(ll i=1;i<=n;i++){
        for(ll j=0;j<g[i].sz;j++){
            if((pref[g[i][j]]-pref[i-1]) & (1ll<<val)){
                swap(g[i][j],g[i].bc);
                g[i].pop_back();
                j--;
            }
        }
    }
}
void solve(){
    ll i,j,q,sum=0,ans=0,b,mx=-1,c=1,m,t;
    ll k;
    cin>>n>>l>>r;
    vector <ll> v;
    v.pb(0);
    for(i=0;i<n;i++){
        cin>>b;
        v.pb(b);
    }
    for(i=1;i<=n;i++){
        pref[i]=pref[i-1]+v[i];
    }
    for(i=1;i<=n;i++){
        for(j=i;j<=n;j++){
            g[i].pb(j);
        }
    }
    for(i=45;i>=0;i--){
        if(check(i)){
            ers(i);
        }
        else{
            ans+=(1ll<<i);
        }
    }
    cout<<ans<<endl;

}
signed main(){
    //start();
    //fre("");
    ll t=1;
    //cin>>t;
    while(t--) solve();
}
/*
6 1 3
8 1 2 1 5 4
*/

Compilation message

sculpture.cpp: In function 'void ers(long long int)':
sculpture.cpp:66:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 |         for(ll j=0;j<g[i].sz;j++){
      |                     ^
sculpture.cpp: In function 'void solve()':
sculpture.cpp:76:12: warning: unused variable 'q' [-Wunused-variable]
   76 |     ll i,j,q,sum=0,ans=0,b,mx=-1,c=1,m,t;
      |            ^
sculpture.cpp:76:14: warning: unused variable 'sum' [-Wunused-variable]
   76 |     ll i,j,q,sum=0,ans=0,b,mx=-1,c=1,m,t;
      |              ^~~
sculpture.cpp:76:28: warning: unused variable 'mx' [-Wunused-variable]
   76 |     ll i,j,q,sum=0,ans=0,b,mx=-1,c=1,m,t;
      |                            ^~
sculpture.cpp:76:34: warning: unused variable 'c' [-Wunused-variable]
   76 |     ll i,j,q,sum=0,ans=0,b,mx=-1,c=1,m,t;
      |                                  ^
sculpture.cpp:76:38: warning: unused variable 'm' [-Wunused-variable]
   76 |     ll i,j,q,sum=0,ans=0,b,mx=-1,c=1,m,t;
      |                                      ^
sculpture.cpp:76:40: warning: unused variable 't' [-Wunused-variable]
   76 |     ll i,j,q,sum=0,ans=0,b,mx=-1,c=1,m,t;
      |                                        ^
sculpture.cpp:77:8: warning: unused variable 'k' [-Wunused-variable]
   77 |     ll k;
      |        ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 356 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 356 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 352 KB Output is correct
10 Correct 1 ms 356 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 352 KB Output is correct
16 Correct 1 ms 356 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 360 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 356 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 352 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 356 KB Output is correct
36 Correct 1 ms 352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 352 KB Output is correct
3 Correct 1 ms 356 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 356 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 352 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 356 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 2 ms 340 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 2 ms 340 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 2 ms 340 KB Output is correct
34 Correct 3 ms 356 KB Output is correct
35 Correct 2 ms 340 KB Output is correct
36 Correct 3 ms 372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 360 KB Output is correct
2 Correct 1 ms 356 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 352 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 356 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 2 ms 340 KB Output is correct
18 Correct 4 ms 340 KB Output is correct
19 Correct 3 ms 352 KB Output is correct
20 Correct 3 ms 340 KB Output is correct
21 Correct 3 ms 352 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 3 ms 340 KB Output is correct
24 Correct 3 ms 352 KB Output is correct
25 Correct 4 ms 376 KB Output is correct
26 Correct 6 ms 356 KB Output is correct
27 Correct 9 ms 352 KB Output is correct
28 Correct 11 ms 340 KB Output is correct
29 Correct 11 ms 340 KB Output is correct
30 Correct 14 ms 420 KB Output is correct
31 Correct 13 ms 416 KB Output is correct
32 Correct 13 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 352 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 352 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 360 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 0 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 352 KB Output is correct
38 Correct 1 ms 352 KB Output is correct
39 Correct 2 ms 340 KB Output is correct
40 Correct 2 ms 352 KB Output is correct
41 Correct 2 ms 340 KB Output is correct
42 Correct 2 ms 340 KB Output is correct
43 Correct 2 ms 356 KB Output is correct
44 Correct 2 ms 340 KB Output is correct
45 Correct 3 ms 340 KB Output is correct
46 Correct 2 ms 340 KB Output is correct
47 Correct 3 ms 340 KB Output is correct
48 Correct 5 ms 340 KB Output is correct
49 Correct 7 ms 340 KB Output is correct
50 Correct 10 ms 340 KB Output is correct
51 Correct 14 ms 340 KB Output is correct
52 Correct 11 ms 416 KB Output is correct
53 Correct 13 ms 340 KB Output is correct
54 Correct 12 ms 356 KB Output is correct
55 Correct 13 ms 340 KB Output is correct
56 Correct 1 ms 340 KB Output is correct
57 Correct 3 ms 340 KB Output is correct
58 Correct 4 ms 340 KB Output is correct
59 Correct 5 ms 340 KB Output is correct
60 Correct 5 ms 356 KB Output is correct
61 Correct 6 ms 340 KB Output is correct
62 Correct 6 ms 340 KB Output is correct
63 Correct 5 ms 340 KB Output is correct
64 Correct 10 ms 404 KB Output is correct
65 Correct 2 ms 340 KB Output is correct
66 Correct 2 ms 352 KB Output is correct
67 Correct 4 ms 340 KB Output is correct
68 Correct 5 ms 340 KB Output is correct
69 Correct 5 ms 340 KB Output is correct
70 Correct 4 ms 340 KB Output is correct
71 Correct 5 ms 340 KB Output is correct
72 Correct 6 ms 348 KB Output is correct
73 Correct 5 ms 340 KB Output is correct
74 Correct 6 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 360 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 356 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 352 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 2 ms 340 KB Output is correct
27 Correct 2 ms 340 KB Output is correct
28 Correct 3 ms 340 KB Output is correct
29 Correct 2 ms 340 KB Output is correct
30 Correct 3 ms 340 KB Output is correct
31 Correct 3 ms 340 KB Output is correct
32 Correct 2 ms 356 KB Output is correct
33 Correct 3 ms 352 KB Output is correct
34 Correct 2 ms 340 KB Output is correct
35 Correct 4 ms 340 KB Output is correct
36 Correct 6 ms 392 KB Output is correct
37 Correct 9 ms 356 KB Output is correct
38 Correct 12 ms 412 KB Output is correct
39 Correct 11 ms 412 KB Output is correct
40 Correct 12 ms 340 KB Output is correct
41 Correct 12 ms 340 KB Output is correct
42 Correct 12 ms 416 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 4 ms 356 KB Output is correct
45 Correct 4 ms 340 KB Output is correct
46 Correct 5 ms 340 KB Output is correct
47 Correct 5 ms 412 KB Output is correct
48 Correct 5 ms 340 KB Output is correct
49 Correct 5 ms 340 KB Output is correct
50 Correct 6 ms 340 KB Output is correct
51 Correct 5 ms 340 KB Output is correct
52 Correct 483 ms 2244 KB Output is correct
53 Execution timed out 1039 ms 3632 KB Time limit exceeded
54 Halted 0 ms 0 KB -