sc2017新高二&高一模拟赛7 总结
2017-08-24 15:54
369 查看
这次比赛就三道大水题,没什么好说的,有13个人AK……
CODE:
CODE:
T1:纸牌(SMOJ2063)
题目分析:就是田忌赛马的升级版,一个很简单的贪心。对于自己的每一张牌,找一个点数比它小且尽可能大的没有被匹配过的对手的牌进行匹配,当对手打出某张牌时,我们打出对应的牌即为最优。CODE:
#include<iostream> #include<string> #include<cstring> #include<cmath> #include<cstdio> #include<cstdlib> #include<stdio.h> #include<algorithm> using namespace std; const int maxn=50010; bool vis[maxn<<1]; int n; int main() { freopen("2063.in","r",stdin); freopen("2063.out","w",stdout); scanf("%d",&n); for (int i=1; i<=n; i++) { int x; scanf("%d",&x); vis[x]=true; } n<<=1; int ans=0,num=0; for (int i=n; i>=1; i--) if (vis[i]) num++; else if (num) num--,ans++; printf("%d\n",ans); return 0; }
T2:杯具(SMOJ2064)
题目分析:直接记忆化宽搜即可,记f[i][j]表示第一个杯子的水量为i,第二个杯子水量为j所需要的最少操作步数,统计答案的时候扫一遍f数组。CODE:
#include<iostream> #include<string> #include<cstring> #include<cmath> #include<cstdio> #include<cstdlib> #include<stdio.h> #include<algorithm> using namespace std; const int maxn=105; int qx[maxn*maxn]; int qy[maxn*maxn]; int head=0,tail=1; int num[maxn][maxn]; int n,m,t,d; int Abs(int x) { if (x>0) return x; return -x; } int main() { freopen("2064.in","r",stdin); freopen("2064.out","w",stdout); scanf("%d%d%d%d",&n,&m,&t,&d); qx[1]=0; qy[1]=0; num[0][0]=1; while (head<tail) { head++; int x=qx[head],y=qy[head]; if (num[x][y]==t+1) break; if (!num[x][m]) { num[x][m]=num[x][y]+1; tail++; qx[tail]=x; qy[tail]=m; } if (!num [y]) { num [y]=num[x][y]+1; tail++; qx[tail]=n; qy[tail]=y; } if (!num[x][0]) { num[x][0]=num[x][y]+1; tail++; qx[tail]=x; qy[tail]=0; } if (!num[0][y]) { num[0][y]=num[x][y]+1; tail++; qx[tail]=0; qy[tail]=y; } int tp=min(n-x,y); if (!num[x+tp][y-tp]) { num[x+tp][y-tp]=num[x][y]+1; tail++; qx[tail]=x+tp; qy[tail]=y-tp; } tp=min(x,m-y); if (!num[x-tp][y+tp]) { num[x-tp][y+tp]=num[x][y]+1; tail++; qx[tail]=x-tp; qy[tail]=y+tp; } } int ans=1e9; for (int i=0; i<=n; i++) for (int j=0; j<=m; j++) if (num[i][j]) ans=min(ans, Abs(i+j-d) ); printf("%d\n",ans); return 0; }
T3:辣鸡(SMOJ2065)
题目分析:同sc2017新高二&高一模拟赛5第一题。相关文章推荐
- sc2017新高二&高一模拟赛7 总结
- sc2017新高二&高一模拟赛6 总结
- sc2017新高二&高一模拟赛9 总结
- sc2017新高二&高一模拟赛3 总结
- sc2017新高二&高一模拟赛2 总结
- sc2017新高二&高一模拟赛1 总结
- sc2017新高二&高一模拟赛8 总结
- sc2017新高二&高一模拟赛4 总结
- sc2017新高二&高一模拟赛5 总结
- sc2017新高二&高一模拟赛2 总结
- 高二&高一&初三模拟赛17 总结
- sc2017新高二&初三模拟赛11 总结
- 高二&高一&初三模拟赛20 总结
- 高二&高一模拟赛13 总结
- 高二&高一&初三模拟赛16 总结
- 高二&高一&初三模拟赛26 总结
- 高二&高一&初三模拟赛24 总结
- 高二&高一&初三模拟赛16 总结
- 高二&高一&初三模拟赛23 总结
- 高二&高一&初三模拟赛19 总结