这次比赛(2018年第二届河北省大学生程序设计竞赛)虽然没有打,但是题目还是要写的。未完成的题目(还差比较硬核的四题)和思路分析会陆续更新完。
Problem A 2011 Mex Query
/*
* Operation China Wall
* Author: Zuiho
* Date: 2018-05
* Problem: 2011-Mex Query
*/
#include <bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define QUICKIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using ll=long long;
using ull=unsigned long long;
int main()
{
QUICKIO
unordered_map<int,int> m;
int n,T; cin>>T;
bool firstLine=true;
while(T--)
{
//if(firstLine) firstLine=false;
//else cout<<endl;
cin>>n; m.clear();
int maxm=0;
rep(i,1,n)
{
int tmp; cin>>tmp;
m[tmp]++;
maxm=max(maxm,tmp);
}
rep(i,0,maxm)
{
if(m[i]==0)
{
cout<<i<<endl; break;
}
}
}
return 0;
}
Problem B 2012 icebound的商店
/*
* Operation China Wall
* Author: Zuiho
* Date: 2018-05
* Problem: 2012-Icebound's Shops
* Tips: A Simple DP.
*/
#include <bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
using namespace std;
using ll=long long;
using ull=unsigned long long;
const int mod=1000000009;
ll dp[20][3005];
int w[20]={
0,1,2};
/*
dp[i][j]=dp[1~i][j-w[1~i]]
*/
ll solve(int x,int y)
{
if(dp[x][y]!=-1)
return dp[x][y];
else
{
//cout<<"?"<<endl;
if(y==0) return dp[x][y]=1;
ll ans=0;
rep(i,1,x)
{
//printf("%d,%d\n",y,w[i]);
if(y-w[i]>=0)
ans=(ans+solve(i,y-w[i]))%mod;
else