답안 #146495

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
146495 2019-08-24T09:21:41 Z LittleFlowers__ Bali Sculptures (APIO15_sculpture) C++14
0 / 100
2 ms 376 KB
#include<bits/stdc++.h>
using namespace std;

#define in ({ll x=0;int n=0,c=getchar();for(;!isdigit(c);c=getchar()) n=c=='-';for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
#define inchar ({char c=getchar();while(c==' '||c=='\n') c=getchar();c;})
#define instring ({string s;char c=getchar();while(c==' '||c=='\n') c=getchar();while(c!=' '&&c!='\n') s+=c,c=getchar();s;})

#define ll long long
#define FOR(i,a,b) for(auto i=a;i<=b;i++)
#define ROF(i,a,b) for(auto i=b;a<=i;i--)
#define rr(x) " "<<#x<<'='<<x<<" "

#define bit(x,i) ((x>>(i-1))&1ll)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1ll<<(i-1)))
#define pow2(x) (1ll<<x)

#define mt make_tuple
#define pi pair<int,int>
#define x first
#define y second

#define VEC(i,a) for(auto&i:a)
#define pb push_back
#define allv(a) a.begin(),a.end()
#define endv(a) (int)a.size()-1

#define ifnot(x) if(!(x))
#define middle(a,b) (a+(b-(a))/2)
#define bp(x) ((x)*(x))
#define bitnum(x) __builtin_popcountll(x)
////////////////////////////////////////// NIRO
#define int ll
const int N=2005;
int n,A,B;
ll a[N];

int s[N];
int f[N][N];

ll all;
ll SUM(int u,int v){ll res=s[v]-s[u-1];return (res&all)==0;}
main()
{
    //freopen("nr.inp","r",stdin);
    n=in,A=in,B=in;
    FOR(i,1,n) a[i]=in;
    FOR(i,1,n) s[i]=s[i-1]+a[i];
    ROF(bit,1,41)
    {
        all=on(all,bit);
        if(n<=100)
        {
            FOR(i,1,n) f[i][1]=SUM(1,i);
            FOR(i,1,n) FOR(j,2,B){
                FOR(k,1,i-1) if(f[k][j-1]&&SUM(k+1,i)) f[i][j]=1;
            }
            all=off(all,bit);
            FOR(i,A,B) if(f[n][i]) all=on(all,bit);
        }
        else
        {
            ll las=1,cnt=0;
            FOR(i,1,n) if(!SUM(las,i)) las=i,cnt++;

            all=off(all,bit);
            if(cnt<=B) all=on(all,bit);
        }
    }
    FOR(i,1,41) {if(bit(all,i)) all=off(all,i);else all=on(all,i);}
    cout<<all;
}

Compilation message

sculpture.cpp:43:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -