Submission #734792

# Submission time Handle Problem Language Result Execution time Memory
734792 2023-05-03T05:50:59 Z ReLice Bali Sculptures (APIO15_sculpture) C++14
0 / 100
1000 ms 460 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);
bool check(ll v,ll val,ll d){
    if(v==n+1 && l<=d && d<=r) return true;
    for(auto i : g[v]){
        if((pref[i]-pref[v-1]) & (1<<val)) continue;
        if(check(i+1,val,d+1)){
            return true;
        }
    }
    return false;
}
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])&(1<<val)){
                if(j!=g[i].sz-1){
                    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=30;i>=0;i--){
        if(check(1,i,0)){
            ers(i);
        }
        else{
            ans+=(1<<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:39: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]
   39 |         for(ll j=0;j<g[i].sz;j++){
      |                     ^
sculpture.cpp:41: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]
   41 |                 if(j!=g[i].sz-1){
      |                    ~^~~~~~~~~~~
sculpture.cpp: In function 'void solve()':
sculpture.cpp:51:12: warning: unused variable 'q' [-Wunused-variable]
   51 |     ll i,j,q,sum=0,ans=0,b,mx=-1,c=1,m,t;
      |            ^
sculpture.cpp:51:14: warning: unused variable 'sum' [-Wunused-variable]
   51 |     ll i,j,q,sum=0,ans=0,b,mx=-1,c=1,m,t;
      |              ^~~
sculpture.cpp:51:28: warning: unused variable 'mx' [-Wunused-variable]
   51 |     ll i,j,q,sum=0,ans=0,b,mx=-1,c=1,m,t;
      |                            ^~
sculpture.cpp:51:34: warning: unused variable 'c' [-Wunused-variable]
   51 |     ll i,j,q,sum=0,ans=0,b,mx=-1,c=1,m,t;
      |                                  ^
sculpture.cpp:51:38: warning: unused variable 'm' [-Wunused-variable]
   51 |     ll i,j,q,sum=0,ans=0,b,mx=-1,c=1,m,t;
      |                                      ^
sculpture.cpp:51:40: warning: unused variable 't' [-Wunused-variable]
   51 |     ll i,j,q,sum=0,ans=0,b,mx=-1,c=1,m,t;
      |                                        ^
sculpture.cpp:52:8: warning: unused variable 'k' [-Wunused-variable]
   52 |     ll k;
      |        ^
# 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 340 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 368 KB Output is correct
7 Correct 6 ms 340 KB Output is correct
8 Correct 44 ms 364 KB Output is correct
9 Correct 49 ms 340 KB Output is correct
10 Correct 45 ms 340 KB Output is correct
11 Correct 149 ms 360 KB Output is correct
12 Correct 44 ms 352 KB Output is correct
13 Correct 1 ms 368 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 372 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 6 ms 340 KB Output is correct
21 Correct 3 ms 340 KB Output is correct
22 Correct 4 ms 340 KB Output is correct
23 Correct 6 ms 340 KB Output is correct
24 Correct 83 ms 348 KB Output is correct
25 Correct 3 ms 372 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Incorrect 1 ms 340 KB Output isn't correct
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 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 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 6 ms 340 KB Output is correct
8 Correct 44 ms 340 KB Output is correct
9 Correct 48 ms 352 KB Output is correct
10 Correct 45 ms 340 KB Output is correct
11 Correct 154 ms 460 KB Output is correct
12 Correct 45 ms 356 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 376 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 368 KB Output is correct
20 Correct 6 ms 340 KB Output is correct
21 Correct 4 ms 368 KB Output is correct
22 Correct 4 ms 340 KB Output is correct
23 Correct 8 ms 372 KB Output is correct
24 Correct 86 ms 340 KB Output is correct
25 Correct 4 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 14 ms 376 KB Output is correct
29 Execution timed out 1075 ms 340 KB Time limit exceeded
30 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 368 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 372 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 6 ms 364 KB Output is correct
8 Correct 48 ms 460 KB Output is correct
9 Correct 48 ms 348 KB Output is correct
10 Correct 45 ms 352 KB Output is correct
11 Correct 147 ms 348 KB Output is correct
12 Correct 48 ms 360 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 14 ms 340 KB Output is correct
16 Execution timed out 1091 ms 364 KB Time limit exceeded
17 Halted 0 ms 0 KB -
# 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 372 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 6 ms 372 KB Output is correct
8 Correct 44 ms 340 KB Output is correct
9 Correct 50 ms 348 KB Output is correct
10 Correct 45 ms 340 KB Output is correct
11 Correct 148 ms 364 KB Output is correct
12 Correct 45 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 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 368 KB Output is correct
20 Correct 6 ms 340 KB Output is correct
21 Correct 3 ms 372 KB Output is correct
22 Correct 5 ms 372 KB Output is correct
23 Correct 5 ms 340 KB Output is correct
24 Correct 82 ms 348 KB Output is correct
25 Correct 4 ms 376 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Incorrect 1 ms 340 KB Output isn't correct
28 Halted 0 ms 0 KB -
# 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 340 KB Output is correct
4 Correct 0 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 6 ms 340 KB Output is correct
8 Correct 44 ms 340 KB Output is correct
9 Correct 48 ms 340 KB Output is correct
10 Correct 47 ms 364 KB Output is correct
11 Correct 147 ms 340 KB Output is correct
12 Correct 43 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Incorrect 1 ms 368 KB Output isn't correct
15 Halted 0 ms 0 KB -