답안 #146505

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
146505 2019-08-24T09:28:22 Z LittleFlowers__ Bali Sculptures (APIO15_sculpture) C++14
0 / 100
4 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(0&&n<=100)
        {
            memset(f,0,sizeof f);
            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 sum=0,cnt=0;
            FOR(i,1,n)
            {
                sum+=a[i];
                if((sum&all)!=0) sum=a[i],cnt++;
            }
            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 Correct 4 ms 376 KB Output is correct
2 Incorrect 2 ms 252 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -