답안 #146513

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
146513 2019-08-24T09:37:58 Z LittleFlowers__ Bali Sculptures (APIO15_sculpture) C++14
71 / 100
374 ms 31996 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)
        {
            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 243 ms 31864 KB Output is correct
2 Correct 242 ms 31736 KB Output is correct
3 Correct 242 ms 31736 KB Output is correct
4 Correct 254 ms 31736 KB Output is correct
5 Correct 374 ms 31736 KB Output is correct
6 Correct 374 ms 31992 KB Output is correct
7 Correct 332 ms 31956 KB Output is correct
8 Correct 242 ms 31736 KB Output is correct
9 Correct 240 ms 31908 KB Output is correct
10 Correct 241 ms 31840 KB Output is correct
11 Correct 252 ms 31868 KB Output is correct
12 Correct 370 ms 31868 KB Output is correct
13 Correct 239 ms 31864 KB Output is correct
14 Correct 241 ms 31864 KB Output is correct
15 Correct 231 ms 31840 KB Output is correct
16 Correct 238 ms 31836 KB Output is correct
17 Correct 240 ms 31992 KB Output is correct
18 Correct 240 ms 31992 KB Output is correct
19 Correct 235 ms 31864 KB Output is correct
20 Correct 233 ms 31872 KB Output is correct
21 Correct 236 ms 31864 KB Output is correct
22 Correct 242 ms 31964 KB Output is correct
23 Correct 243 ms 31864 KB Output is correct
24 Correct 243 ms 31736 KB Output is correct
25 Correct 237 ms 31748 KB Output is correct
26 Correct 246 ms 31864 KB Output is correct
27 Correct 243 ms 31860 KB Output is correct
28 Correct 240 ms 31864 KB Output is correct
29 Correct 255 ms 31832 KB Output is correct
30 Correct 233 ms 31864 KB Output is correct
31 Correct 247 ms 31832 KB Output is correct
32 Correct 248 ms 31864 KB Output is correct
33 Correct 250 ms 31908 KB Output is correct
34 Correct 247 ms 31992 KB Output is correct
35 Correct 242 ms 31736 KB Output is correct
36 Correct 217 ms 31864 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 244 ms 31836 KB Output is correct
2 Correct 272 ms 31836 KB Output is correct
3 Correct 239 ms 31864 KB Output is correct
4 Correct 244 ms 31736 KB Output is correct
5 Correct 240 ms 31964 KB Output is correct
6 Correct 261 ms 31864 KB Output is correct
7 Correct 244 ms 31864 KB Output is correct
8 Correct 281 ms 31856 KB Output is correct
9 Correct 239 ms 31864 KB Output is correct
10 Correct 241 ms 31964 KB Output is correct
11 Correct 247 ms 31864 KB Output is correct
12 Correct 373 ms 31864 KB Output is correct
13 Correct 239 ms 31992 KB Output is correct
14 Correct 225 ms 31992 KB Output is correct
15 Correct 241 ms 31864 KB Output is correct
16 Correct 242 ms 31864 KB Output is correct
17 Correct 239 ms 31864 KB Output is correct
18 Correct 247 ms 31864 KB Output is correct
19 Correct 236 ms 31864 KB Output is correct
20 Correct 240 ms 31780 KB Output is correct
21 Correct 246 ms 31864 KB Output is correct
22 Correct 240 ms 31864 KB Output is correct
23 Correct 249 ms 31736 KB Output is correct
24 Correct 240 ms 31832 KB Output is correct
25 Correct 302 ms 31992 KB Output is correct
26 Correct 241 ms 31736 KB Output is correct
27 Correct 299 ms 31992 KB Output is correct
28 Correct 248 ms 31864 KB Output is correct
29 Correct 230 ms 31864 KB Output is correct
30 Correct 237 ms 31932 KB Output is correct
31 Correct 306 ms 31864 KB Output is correct
32 Correct 256 ms 31864 KB Output is correct
33 Correct 254 ms 31736 KB Output is correct
34 Correct 238 ms 31996 KB Output is correct
35 Correct 245 ms 31992 KB Output is correct
36 Correct 298 ms 31736 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 359 ms 31844 KB Output is correct
2 Correct 230 ms 31736 KB Output is correct
3 Correct 241 ms 31864 KB Output is correct
4 Correct 242 ms 31736 KB Output is correct
5 Correct 245 ms 31864 KB Output is correct
6 Correct 247 ms 31840 KB Output is correct
7 Correct 242 ms 31736 KB Output is correct
8 Correct 234 ms 31864 KB Output is correct
9 Correct 239 ms 31776 KB Output is correct
10 Correct 242 ms 31864 KB Output is correct
11 Correct 239 ms 31864 KB Output is correct
12 Correct 244 ms 31736 KB Output is correct
13 Correct 236 ms 31864 KB Output is correct
14 Correct 239 ms 31736 KB Output is correct
15 Correct 231 ms 31736 KB Output is correct
16 Correct 242 ms 31784 KB Output is correct
17 Correct 253 ms 31736 KB Output is correct
18 Correct 242 ms 31864 KB Output is correct
19 Correct 238 ms 31736 KB Output is correct
20 Correct 221 ms 31736 KB Output is correct
21 Correct 280 ms 31736 KB Output is correct
22 Correct 275 ms 31832 KB Output is correct
23 Correct 238 ms 31864 KB Output is correct
24 Correct 237 ms 31736 KB Output is correct
25 Correct 247 ms 31864 KB Output is correct
26 Correct 254 ms 31736 KB Output is correct
27 Correct 254 ms 31864 KB Output is correct
28 Correct 269 ms 31736 KB Output is correct
29 Correct 272 ms 31864 KB Output is correct
30 Correct 228 ms 31736 KB Output is correct
31 Correct 257 ms 31944 KB Output is correct
32 Correct 268 ms 31872 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 265 ms 31828 KB Output is correct
2 Correct 270 ms 31872 KB Output is correct
3 Correct 243 ms 31736 KB Output is correct
4 Correct 233 ms 31888 KB Output is correct
5 Correct 239 ms 31992 KB Output is correct
6 Correct 241 ms 31736 KB Output is correct
7 Correct 226 ms 31864 KB Output is correct
8 Correct 291 ms 31992 KB Output is correct
9 Correct 275 ms 31964 KB Output is correct
10 Correct 234 ms 31864 KB Output is correct
11 Correct 236 ms 31864 KB Output is correct
12 Correct 240 ms 31864 KB Output is correct
13 Correct 236 ms 31864 KB Output is correct
14 Correct 258 ms 31864 KB Output is correct
15 Correct 241 ms 31760 KB Output is correct
16 Correct 234 ms 31992 KB Output is correct
17 Correct 236 ms 31992 KB Output is correct
18 Correct 236 ms 31736 KB Output is correct
19 Correct 304 ms 31864 KB Output is correct
20 Correct 250 ms 31872 KB Output is correct
21 Correct 240 ms 31864 KB Output is correct
22 Correct 236 ms 31836 KB Output is correct
23 Correct 234 ms 31736 KB Output is correct
24 Correct 239 ms 31864 KB Output is correct
25 Correct 290 ms 31864 KB Output is correct
26 Correct 246 ms 31992 KB Output is correct
27 Correct 233 ms 31864 KB Output is correct
28 Correct 237 ms 31864 KB Output is correct
29 Correct 248 ms 31992 KB Output is correct
30 Correct 246 ms 31912 KB Output is correct
31 Correct 234 ms 31864 KB Output is correct
32 Correct 247 ms 31864 KB Output is correct
33 Correct 287 ms 31864 KB Output is correct
34 Correct 304 ms 31736 KB Output is correct
35 Correct 271 ms 31864 KB Output is correct
36 Correct 232 ms 31864 KB Output is correct
37 Correct 241 ms 31828 KB Output is correct
38 Correct 245 ms 31964 KB Output is correct
39 Correct 296 ms 31836 KB Output is correct
40 Correct 240 ms 31808 KB Output is correct
41 Correct 267 ms 31964 KB Output is correct
42 Correct 240 ms 31864 KB Output is correct
43 Correct 241 ms 31992 KB Output is correct
44 Correct 249 ms 31864 KB Output is correct
45 Correct 250 ms 31864 KB Output is correct
46 Correct 246 ms 31864 KB Output is correct
47 Correct 243 ms 31832 KB Output is correct
48 Correct 243 ms 31864 KB Output is correct
49 Correct 252 ms 31864 KB Output is correct
50 Correct 248 ms 31864 KB Output is correct
51 Correct 266 ms 31736 KB Output is correct
52 Correct 259 ms 31864 KB Output is correct
53 Correct 239 ms 31736 KB Output is correct
54 Correct 255 ms 31856 KB Output is correct
55 Correct 333 ms 31992 KB Output is correct
56 Correct 243 ms 31864 KB Output is correct
57 Correct 247 ms 31864 KB Output is correct
58 Correct 251 ms 31864 KB Output is correct
59 Correct 261 ms 31864 KB Output is correct
60 Correct 263 ms 31812 KB Output is correct
61 Correct 243 ms 31840 KB Output is correct
62 Correct 264 ms 31864 KB Output is correct
63 Correct 271 ms 31736 KB Output is correct
64 Correct 255 ms 31864 KB Output is correct
65 Correct 233 ms 31736 KB Output is correct
66 Correct 234 ms 31912 KB Output is correct
67 Correct 241 ms 31876 KB Output is correct
68 Correct 289 ms 31836 KB Output is correct
69 Correct 267 ms 31736 KB Output is correct
70 Correct 309 ms 31964 KB Output is correct
71 Correct 263 ms 31836 KB Output is correct
72 Correct 279 ms 31864 KB Output is correct
73 Correct 308 ms 31864 KB Output is correct
74 Correct 260 ms 31864 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 230 ms 31864 KB Output is correct
2 Correct 249 ms 31864 KB Output is correct
3 Correct 241 ms 31864 KB Output is correct
4 Correct 248 ms 31864 KB Output is correct
5 Correct 247 ms 31864 KB Output is correct
6 Correct 272 ms 31864 KB Output is correct
7 Correct 245 ms 31864 KB Output is correct
8 Correct 243 ms 31864 KB Output is correct
9 Correct 245 ms 31864 KB Output is correct
10 Correct 267 ms 31864 KB Output is correct
11 Correct 238 ms 31864 KB Output is correct
12 Correct 245 ms 31736 KB Output is correct
13 Correct 240 ms 31736 KB Output is correct
14 Correct 241 ms 31996 KB Output is correct
15 Correct 241 ms 31964 KB Output is correct
16 Correct 241 ms 31836 KB Output is correct
17 Correct 243 ms 31840 KB Output is correct
18 Correct 241 ms 31964 KB Output is correct
19 Correct 366 ms 31864 KB Output is correct
20 Correct 235 ms 31736 KB Output is correct
21 Correct 239 ms 31844 KB Output is correct
22 Correct 245 ms 31864 KB Output is correct
23 Correct 225 ms 31832 KB Output is correct
24 Correct 237 ms 31864 KB Output is correct
25 Correct 240 ms 31736 KB Output is correct
26 Correct 244 ms 31992 KB Output is correct
27 Correct 273 ms 31864 KB Output is correct
28 Correct 253 ms 31864 KB Output is correct
29 Correct 243 ms 31864 KB Output is correct
30 Correct 286 ms 31872 KB Output is correct
31 Correct 229 ms 31868 KB Output is correct
32 Correct 247 ms 31964 KB Output is correct
33 Correct 246 ms 31992 KB Output is correct
34 Correct 246 ms 31736 KB Output is correct
35 Correct 249 ms 31864 KB Output is correct
36 Correct 245 ms 31864 KB Output is correct
37 Correct 254 ms 31736 KB Output is correct
38 Correct 279 ms 31992 KB Output is correct
39 Correct 286 ms 31964 KB Output is correct
40 Correct 243 ms 31992 KB Output is correct
41 Correct 259 ms 31736 KB Output is correct
42 Correct 271 ms 31864 KB Output is correct
43 Correct 252 ms 31904 KB Output is correct
44 Correct 247 ms 31916 KB Output is correct
45 Correct 290 ms 31836 KB Output is correct
46 Correct 271 ms 31736 KB Output is correct
47 Correct 267 ms 31964 KB Output is correct
48 Correct 248 ms 31864 KB Output is correct
49 Correct 274 ms 31864 KB Output is correct
50 Correct 373 ms 31928 KB Output is correct
51 Incorrect 3 ms 376 KB Output isn't correct
52 Halted 0 ms 0 KB -