제출 #249857

#제출 시각아이디문제언어결과실행 시간메모리
249857NightlightBali Sculptures (APIO15_sculpture)C++14
100 / 100
355 ms1016 KiB
#include <bits/stdc++.h> using namespace std; int N, A, B; long long pre[2005]; long long mask; bitset<2005> valid[2005]; long long ans = (1LL << 42) - 1; bool check(long long T) { return ((T | mask) ^ mask) == 0; } bool can(int X) { for(int i = 1; i < N; i++) { for(int j = i + 1; j <= N; j++) { valid[i][j] = check(pre[j] - pre[i]); } } bitset<2005> now[2]; for(int j = 1; j <= N; j++) { if(check(pre[j])) { now[1] |= valid[j]; } } if(A == 1 && check(pre[N])) return 1; int skrg, sblm; for(int i = 2; i <= B; i++) { skrg = i & 1, sblm = !skrg; now[skrg] = 0; for(int j = i; j <= N; j++) { if(now[sblm][j]) { now[skrg] |= valid[j]; } } if(i >= A && now[sblm][N]) return 1; } return 0; } int main() { scanf("%d %d %d", &N, &A, &B); for(int i = 1; i <= N; i++) { scanf("%lld", &pre[i]); pre[i] += pre[i - 1]; } for(int i = 41; i >= 0; i--) { mask = ans - (1LL << i); if(can(i)) { ans -= (1LL << i); } } printf("%lld\n", ans); }

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

sculpture.cpp: In function 'int main()':
sculpture.cpp:43:8: 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:45:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld", &pre[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...