Submission #21945

# Submission time Handle Problem Language Result Execution time Memory
21945 2017-04-27T18:29:11 Z mohammad_kilani Bali Sculptures (APIO15_sculpture) C++14
0 / 100
0 ms 3024 KB
#include<bits/stdc++.h>
using namespace std;
const int N = 101;
int n , a , b , arr[N];
bool dp[N][N][50];
bool vis[N][N][50];
bool cantake[N][N];
bool solve(int i,int j,int bit){
    if(j > b)
        return 0;
    if(i == n){
        if(j >= a && j <= b)
            return 1;
        return 0;
    }
    if(vis[i][j][bit])
        return dp[i][j][bit];
    vis[i][j][bit] = true;
    long long sum = 0;
    bool can = false;
    for(int k=i;k<n;k++){
        sum+=arr[k];
        if(((sum >> bit)&1) == 0 && cantake[k+1][j+1] && solve(k+1,j+1,bit)){
            can = true;
        }
    }
    if(can){
        sum =0  ;
        for(int k=i;k<n;k++){
             sum+=arr[k];
            if(!(((sum >> bit)&1) == 0 && cantake[k+1][j+1] && solve(k+1,j+1,bit))){
                cantake[k+1][j+1] = false;
            }
        }
    }
    dp[i][j][bit] = can;
    return dp[i][j][bit];
}
int main(){
    memset(dp,-1,sizeof(dp));
    memset(cantake,1,sizeof(cantake));
    scanf("%d%d%d",&n,&a,&b);
    for(int i=0;i<n;i++)
        scanf("%d",&arr[i]);
    long long ans = 0 ;
    for(int i=46;i>=0;i--){
        if(!solve(0,0,i)){
            ans= (ans | (long long)(1 << i));
        }
    }
    cout << ans << endl;
    return 0;
}

Compilation message

sculpture.cpp: In function 'int main()':
sculpture.cpp:42:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d",&n,&a,&b);
                             ^
sculpture.cpp:44:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&arr[i]);
                            ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 3024 KB Output is correct
2 Correct 0 ms 3024 KB Output is correct
3 Correct 0 ms 3024 KB Output is correct
4 Correct 0 ms 3024 KB Output is correct
5 Correct 0 ms 3024 KB Output is correct
6 Incorrect 0 ms 3024 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 3024 KB Output is correct
2 Correct 0 ms 3024 KB Output is correct
3 Correct 0 ms 3024 KB Output is correct
4 Correct 0 ms 3024 KB Output is correct
5 Correct 0 ms 3024 KB Output is correct
6 Incorrect 0 ms 3024 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 3024 KB Output is correct
2 Correct 0 ms 3024 KB Output is correct
3 Correct 0 ms 3024 KB Output is correct
4 Correct 0 ms 3024 KB Output is correct
5 Correct 0 ms 3024 KB Output is correct
6 Incorrect 0 ms 3024 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 3024 KB Output is correct
2 Correct 0 ms 3024 KB Output is correct
3 Correct 0 ms 3024 KB Output is correct
4 Correct 0 ms 3024 KB Output is correct
5 Correct 0 ms 3024 KB Output is correct
6 Incorrect 0 ms 3024 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 3024 KB Output is correct
2 Correct 0 ms 3024 KB Output is correct
3 Correct 0 ms 3024 KB Output is correct
4 Correct 0 ms 3024 KB Output is correct
5 Correct 0 ms 3024 KB Output is correct
6 Incorrect 0 ms 3024 KB Output isn't correct
7 Halted 0 ms 0 KB -