# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
660849 | danikoynov | Bali Sculptures (APIO15_sculpture) | C++14 | 68 ms | 468 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
const ll maxn = 101, maxbit = 62;
ll n, A, B, f[maxbit], aw[maxn];
ll dp[maxn][maxn][2];
ll a[maxn];
void solve()
{
cin >> n >> A >> B;
for (ll i = 1; i <= n; i ++)
cin >> a[i];
for (ll i = A; i <= B; i ++)
aw[i] = 1;
/// fix bit
for (ll bit = maxbit - 1; bit >= 0; bit --)
{
dp[0][0][0] = dp[0][0][1] = 1;
for (ll i = 1; i <= n; i ++)
for (ll j = 1; j <= B; j ++)
dp[i][j][0] = dp[i][j][1] = 0;
for (ll i = 1; i <= n; i ++)
{
ll sum = 0;
for (ll k = i; k > 0; k --)
{
sum += a[k];
bool done = false;
for (ll fbit = maxbit - 1; fbit > bit; fbit --)
{
if ((sum & ((ll)(1) << fbit)) > 0 && f[fbit] == 0)
{
done = true;
break;
}
}
if (done)
continue;
for (ll j = 1; j <= B; j ++)
{
if (dp[k - 1][j - 1][1] == 1)
dp[i][j][1] = 1;
}
if ((sum & ((ll)(1) << bit)) > 0)
continue;
for (ll j = 1; j <= B; j ++)
{
if (dp[k - 1][j - 1][0] == 1)
dp[i][j][0] = 1;
}
}
} ll st = 1;
for (ll j = A; j <= B; j ++)
{
if (aw[j] && dp[n][j][0] == 1)
st = 0;
}
if (st == 1)
{
f[bit] = 1;
for (ll j = A; j <= B; j ++)
aw[j] = min(aw[j], dp[n][j][1]);
}
else
{
for (ll j = A; j <= B; j ++)
aw[j] = min(aw[j], dp[n][j][0]);
}
//exit(0);
}
ll ans = 0;
for (ll bit = 0; bit < maxbit; bit ++)
if (f[bit])
ans = ans + ((ll)(1) << bit);
cout << ans << endl;
}
int main()
{
solve();
return 0;
}
/**
6 1 3
8 1 2 1 5 4
*/
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |