| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1349924 | the_commando_x | Bali Sculptures (APIO15_sculpture) | C++17 | 4 ms | 464 KiB |
// #pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using vii = vector<pii>;
using vvii = vector<vii>;
using l = long long;
using vl = vector<l>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using pll = pair<l, l>;
using vll = vector<pll>;
using vvll = vector<vll>;
using d = double;
using vd = vector<d>;
using vvd = vector<vd>;
using vvvd = vector<vvd>;
using ld = long double;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using pbb = pair<bool, bool>;
using vbb = vector<pbb>;
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
void setIO(string name = "")
{
ios_base::sync_with_stdio(0);
cin.tie(0);
if (!name.empty())
{
(void)freopen((name + ".in").c_str(), "r", stdin);
(void)freopen((name + ".out").c_str(), "w", stdout);
}
}
const ld pi = 3.14159265358979323846;
const l LINF = 1e18;
const l INF = 1e9;
const l MOD = 1e9 + 7;
// const l MOD = 998244353;
const l MAXN = 1e2 + 5;
int N, A, B;
vl Y(MAXN);
vl prefY(MAXN + 1);
bool canPartition(l mask)
{
vvb dp(MAXN, vb(MAXN, false)); // * [pos][group]
dp[0][0] = true;
for (int g = 0; g <= B; ++g)
{
for (int i = 0; i < N; ++i)
{
if (!dp[i][g])
continue;
if (g == B)
continue;
for (int j = i; j < N; ++j)
if (((prefY[j + 1] - prefY[i]) & mask) == 0)
dp[j + 1][g + 1] = true;
}
}
for (int g = A; g <= B; ++g)
if (dp[N][g])
return true;
return false;
}
void solve()
{
cin >> N >> A >> B;
for (int i = 0; i < N && cin >> Y[i]; ++i)
prefY[i + 1] = prefY[i] + Y[i];
l curMask = 0;
for (int bit = 40; bit >= 0; --bit)
{
l nxtMask = curMask | (1LL << bit);
if (canPartition(nxtMask))
curMask = nxtMask;
}
l ans = ((1LL << 41) - 1) - curMask;
cout << ans;
}
int main()
{
setIO("");
#ifndef ONLINE_JUDGE
// setIO("filename");
#endif
int t = 1;
// cin >> t;
while (t--)
solve();
return 0;
}컴파일 시 표준 에러 (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... | ||||
