打了一个半小时...做出来两道傻逼题。一道傻逼DP给WA了...2333


【A】

手工模拟,WA了一次...

//codeforces A. Vladik and Courtesy
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define ll long long
#define M(a) memset(a,0,sizeof a)
#define fo(i,j,k) for(i=j;i<=k;i++)
using namespace std;
const int mxn=1e9;
int a,b;
int main()
{
int i,j;
scanf("%d%d",&a,&b);
fo(i,1,mxn)
{
if(i&1) a-=i;
else b-=i;
if(a<0) return puts("Vladik"),0;
if(b<0) return puts("Valera"),0;
}
}



【B】

n^2暴力,反正能过

//B.Vladik and Complicated Book
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define ll long long
#define M(a) memset(a,0,sizeof a)
#define fo(i,j,k) for(i=j;i<=k;i++)
using namespace std;
const int mxn=100005;
int n,m,a[mxn];
int main()
{
int i,j,l,r,x;
scanf("%d%d",&n,&m);
fo(i,1,n) scanf("%d",&a[i]);
while(m--)
{
scanf("%d%d%d",&l,&r,&x);
int cnt=0;
fo(j,l,r)
{
if(a[j]<a[x]) cnt++;
if(cnt>x-l) break;
}
if(cnt==x-l) printf("Yes\n");
else printf("No\n");
}
return 0;
}


【C】

预处理出所有合法区间以及n^2个区间的异或值,线性dp一下...

预处理写挂了一次2333

//C
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define ll long long
#define M(a) memset(a,0,sizeof a)
#define fo(i,j,k) for(i=j;i<=k;i++)
using namespace std;
const int mxn=5005;
vector <int> v[mxn];
bool ok[mxn][mxn],vis[mxn];
int ans,n,a[mxn],L[mxn],R[mxn],num[mxn],cnt[mxn];
int dp[mxn],xo[mxn][mxn];
int main()
{
int i,j;
scanf("%d",&n);
memset(L,0x3f,sizeof L);
fo(i,1,n)
{
scanf("%d",&a[i]);
num[a[i]]++;
L[a[i]]=min(L[a[i]],i);
R[a[i]]=max(R[a[i]],i);
}
fo(i,1,n)
{
int sum=0,now=0;
M(vis),M(cnt);
fo(j,i,n)
{
if(!vis[a[j]]) sum++,vis[a[j]]=1;
cnt[a[j]]++;
if(cnt[a[j]]==num[a[j]]) now++;
if(now==sum) ok[i][j]=1,v[j].push_back(i);
}
}
fo(i,1,n)
{
M(vis);
int x=0;
fo(j,i,n)
{
if(!vis[a[j]]) x^=a[j];
xo[i][j]=x,vis[a[j]]=1;
}
}
fo(i,1,n)
{
dp[i]=dp[i-1];
for(j=0;j<v[i].size();j++)
{
int x=v[i][j];
dp[i]=max(dp[i],dp[x-1]+xo[x][i]);
}
}
printf("%d\n",dp[n]);
return 0;
}
/*
8
5 1 3 1 5 2 4 2
*/