이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,avx2,fma,bmi,bmi2")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int n, A, B;
ull x[2001], pref[2001];
int main()
{
cin.tie(0)->sync_with_stdio(0);
cin >> n >> A >> B;
for (int i = 1; i <= n; i++)
cin >> x[i];
pref[0] = 0;
for (int i = 1; i <= n; i++)
pref[i] = pref[i-1] + x[i];
ull mask = 0;
vector<pair<int,int>> segments = {{1, n}};
for (ull y = 1LL << 63; y; y >>= 1)
{
vector<pair<int,int>> new_segments;
bool possible = true;
for (auto [L, R] : segments)
{
for (int l = L; l <= R; l++)
{
possible = false;
for (int r = R; r >= l; r--)
if (((pref[r] - pref[l-1]) & (mask | y)) == 0)
{
new_segments.push_back({l, r});
l = r;
possible = true;
break;
}
if (!possible) break;
}
if (!possible) break;
}
if (possible && new_segments.size() <= B)
segments = new_segments, mask |= y;
}
/*
for (auto [l, r] : segments)
cout << "(" << l << ", " << r << ") ";
cout << '\n';
*/
cout << (~mask) << '\n';
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
sculpture.cpp: In function 'int main()':
sculpture.cpp:46:45: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
46 | if (possible && new_segments.size() <= B)
| ~~~~~~~~~~~~~~~~~~~~^~~~
# | 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... |