제출 #21967

#제출 시각아이디문제언어결과실행 시간메모리
21967mohammad_kilaniBali Sculptures (APIO15_sculpture)C++14
71 / 100
1000 ms180364 KiB
#include<bits/stdc++.h>
using namespace std;
const int N = 2001;
int n , a , b , arr[N];
bool dp[N][N][41];
bool cangroup[N][N];
bool cansum[N][N];
bool vis[N][N];
bool canbit[41];
vector<vector<int> > v;
bool check(long long num,int curbit){
    for(int i=46;i>=curbit;i--){
        if(canbit[i] == 1)
           continue;
        if(((num >> i)&1) == 1)
            return false;
    }
    return true;
}

int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    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=40;i>=0;i--){
        v.clear();
        v.resize(n+2);
        memset(vis,0,sizeof(vis));
        for(int j=0;j<n;j++){
            long long sum =0;
            for(int k=j;k<n;k++){
                sum+=(long long)arr[k];
                if(check(sum,i)){
                    v[k].push_back(j);
                }
            }
        }
        queue<pair<int,int> > q;
        for(int j=b;j>=a;j--){
            q.push(make_pair(n-1,j-1));
            vis[n-1][j-1] = true;

        }
        while(!q.empty()){
            int k = q.front().first;
            int j = q.front().second;
            q.pop();
            int si = v[k].size();
            for(int l=0;l<si;l++){
                dp[v[k][l]][j][i] = true;
                if(j == 0 || v[k][l]-1 < 0 || vis[v[k][l]-1][j-1])
                    continue;
                vis[v[k][l]-1][j-1] = true;
                q.push(make_pair(v[k][l]-1,j-1));
            }
        }
        if(dp[0][0][i] == false){
            ans += ((long long)1 << (long long)i);
            canbit[i] = 1;
        }

    }
    cout << ans << endl;
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

sculpture.cpp: In function 'int main()':
sculpture.cpp:24: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:26:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&arr[i]);
                            ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...