This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define sc second
//#define endl "\n"
#define pii pair<int,int>
using namespace std;
const int MAXN = 2e3+5;
const int mod7 = 1e9+7;
const long long inf = 1e18;
vector<vector<int>> sums(MAXN,vector<int>(MAXN));
int n,a,b;
int pref[MAXN];
void checka1(int& ans, int bt)
{
vector<int> dp(MAXN, inf);
dp[0] = 0;
for(int i=1; i<=n; i++)
{
for(int j=i; j>0; j--)
{
int trsum = pref[i]- pref[j-1];
int p = trsum^ans;
if(p >=(1<<bt))continue;
dp[i] = min(dp[i],dp[j-1] + 1);
}
}
if(dp[n] > b)ans|=(1<<bt);
}
signed main()
{
ios_base::sync_with_stdio(false),cin.tie(0), cout.tie(0);
int tt=1;
//cin >> tt;
while(tt--)
{
cin >> n >> a >> b;
vector<int>niz(n);
for(int i=0; i<n; i++)
{
cin >> niz[i];
pref[i+1] = pref[i] + niz[i];
}
for(int i=0; i<n; i++)for(int j=i; j<n; j++)sums[i][j] = pref[i+1]-pref[j];
if(a == 1)
{
int rez = 0;
for(int i=63; i>=0; i--)checka1(rez, i);
cout << rez << endl;
}
else
{
}
}
}
/*
6 1 3
8 1 2 1 5 4
*/
# | 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... |