题目地址:http://codeforces.com/contest/493

A题

  写完后就交了,然后WA了,又读了一遍题,没找出错误后就开始搞B题了,后来回头重做的时候才发现,球员被红牌罚下场后还可以再出现,但不能再参与计算,这里需要开一个flag数组判重 。打比赛时要调整好心态。

 #include<cstdio>
#include<iostream>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<cmath>
#include<algorithm>
#include<time.h> using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define clr(x,y) memset(x,y,sizeof(x))
#define sqr(x) ((x)*(x))
#define LL long long
char sth[],sta[];
int num[][];
bool flag[][]; int main()
{
int t,ni,n,i;
char p1[],p2[],name[]; scanf("%s",sth);
scanf("%s",sta);
scanf("%d",&n);
clr(flag,); while(n--) {
scanf("%d%s%d%s",&t,p1,&ni,p2);
if(p2[]=='y') {
if(!num[ni][p1[]-'a']) {
num[ni][p1[]-'a']++;
} else {
if(!flag[ni][p1[]-'a']){
if(p1[]=='h') printf("%s ",sth);
else printf("%s ",sta);
printf("%d %d\n",ni,t);
flag[ni][p1[]-'a']=;
}
}
} else {
if(!flag[ni][p1[]-'a']){
if(p1[]=='h') printf("%s ",sth);
else printf("%s ",sta);
printf("%d %d\n",ni,t);
flag[ni][p1[]-'a']=;
}
}
} return ;
}

B题

  出现了一个 lexicographically greater的规则。读了很多遍题后才明白题意,其实就是比较两个序列的字典序,浪费了大量时间。首先比较得分大小,得分大的输出。得分相同则比较两个序列的字典序,如果字典序相同,最后一个是谁赢就输出谁。英语读题能力亟待提高。

 #include<cstdio>
#include<iostream>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<cmath>
#include<algorithm>
#include<time.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define clr(x,y) memset(x,y,sizeof(x))
#define sqr(x) ((x)*(x))
#define LL long long const int N=*1e5+; int n,x;
int num1[N],num2[N],head1,head2;
LL sum1=,sum2=; int check(int a,int b)
{
int i;
int m=min(a,b);
for(int i=;i<=m;i++) {
if(num1[i]>num2[i]) {
puts("first");
exit();
}
if(num1[i]<num2[i]) {
puts("second");
exit();
}
} if(a>b) puts("first");
else {
if(a==b) {
if(x<) puts("second");
else puts("first");
}
if(a<b)
puts("second");
} } int main()
{
head1=; head2=;
scanf("%d",&n);
while(n--) {
cin>>x;
if(x>) {
head1++;
num1[head1]=x;
sum1+=x;
} else {
head2++;
num2[head2]=-x;
sum2+=-x;
}
} if(sum1!=sum2) {
if(sum1>sum2) puts("first");
else puts("second");
} else {
check(head1,head2);
} return ;
}

C题

二分查找三分线距离,使得一队得分减二队得分最大。

 #include<cstdio>
#include<iostream>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<cmath>
#include<algorithm>
#include<time.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define clr(x,y) memset(x,y,sizeof(x))
#define sqr(x) ((x)*(x))
#define LL long long
const int N=2e5+;
int a[N],b[N],c[*N]; int main()
{
int n,m,p,t1,t2,s1,s2;
LL ret1,ret2,maxi=-1000000000LL;
scanf("%d",&n);
for(int i=;i<n;i++) {
scanf("%d",&a[i]);
c[i]=a[i];
}
scanf("%d",&m);
for(int i=;i<m;i++) {
scanf("%d",&b[i]);
c[n+i]=b[i];
} sort(a,a+n);sort(b,b+m);sort(c,c+m+n+); for(int i=;i<n+m+;i++) {
p=c[i];
t1=upper_bound(a,a+n,p)-a;
s1=*t1+*(n-t1);
t2=upper_bound(b,b+m,p)-b;
s2=*t2+*(m-t2);
if(s1-s2>maxi) {
maxi=s1-s2;
ret1=s1;ret2=s2;
}
} cout<<ret1<<":"<<ret2<<endl; return ;
}

D题

  思维题。有一个N*N的棋盘(2 ≤ n ≤ 10^9) 左上角(1,1)有一个白皇后,右上角(1,n)一个黑色皇后,其它地方填满小兵。每次可以吃掉小兵或对方皇后。如果上下左右对角线相邻,则下一步就可以把对方吃掉。谁先吃掉对方皇后谁就赢。如果黑皇后赢,输出“black”,白皇后赢输出“white”,然后输出第一步走到的坐标(r,c)。If the answer is "white", then you should also print two integers r and c representing the cell (r, c), where the first player should make his first move to win. If there are multiple such cells, print the one with the minimum r. If there are still multiple squares, print the one with the minimum c

  N分奇数和偶数两种情况讨论。两个人都采用最聪明的策略。每一步则想办法让对方是必败态。则棋手每次下完后保持与对方坐标距离(abs(x1-x2)+abs(y1-y2))是偶数即可。所以N为奇数,黑色赢;N为偶数,白色赢。综上规则,white赢时第一步走的坐标肯定是(1,2)

 #include<cstdio>
#include<iostream>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<cmath>
#include<algorithm>
#include<time.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define clr(x,y) memset(x,y,sizeof(x))
#define sqr(x) ((x)*(x))
#define LL long long int main()
{
int n; scanf("%d",&n);
if(n & ) puts("black");
else puts("white\n1 2"); return ;
}

Codeforces Round #281 (Div. 2) 解题报告的更多相关文章

  1. Codeforces Round #324 (Div. 2)解题报告

    ---恢复内容开始--- Codeforces Round #324 (Div. 2) Problem A 题目大意:给二个数n.t,求一个n位数能够被t整除,存在多组解时输出任意一组,不存在时输出“ ...

  2. Codeforces Round #382 (Div. 2) 解题报告

    CF一如既往在深夜举行,我也一如既往在周三上午的C++课上进行了virtual participation.这次div2的题目除了E题都水的一塌糊涂,参赛时的E题最后也没有几个参赛者AC,排名又成为了 ...

  3. Codeforces Round #380 (Div. 2) 解题报告

    第一次全程参加的CF比赛(虽然过了D题之后就开始干别的去了),人生第一次codeforces上分--(或许之前的比赛如果都参加全程也不会那么惨吧),终于回到了specialist的行列,感动~.虽然最 ...

  4. Codeforces Round #216 (Div. 2)解题报告

    又范低级错误! 只做了两题!一道还被HACK了,囧! A:看了很久!应该是到语文题: 代码:#include<iostream> #include<];    ,m2=;    ;i ...

  5. Codeforces Round #277 (Div. 2) 解题报告

    题目地址:http://codeforces.com/contest/486 A题.Calculating Function 奇偶性判断,简单推导公式. #include<cstdio> ...

  6. Codeforces Round #276 (Div. 2) 解题报告

    题目地址:http://codeforces.com/contest/485 A题.Factory 模拟.判断是否出现循环,如果出现,肯定不可能. 代码: #include<cstdio> ...

  7. Codeforces Round #350 (Div. 2)解题报告

    codeforces 670A. Holidays 题目链接: http://codeforces.com/contest/670/problem/A 题意: A. Holidays On the p ...

  8. Codeforces Round #479 (Div. 3)解题报告

    题目链接: http://codeforces.com/contest/977 A. Wrong Subtraction 题意 给定一个数x,求n次操作输出.操作规则:10的倍数则除10,否则减1 直 ...

  9. Codeforces Round #515 (Div. 3) 解题报告(A~E)

    题目链接:http://codeforces.com/contest/1066 1066 A. Vova and Train 题意:Vova想坐火车从1点到L点,在路上v的整数倍的点上分布着灯笼,而在 ...

随机推荐

  1. 初识Mybatis框架,实现增删改查等操作

    此第一次接触Mybatis框架确实是有点不适应,特别是刚从Hibernate框架转转型过来,那么为什么要使用Mybatis框架,Mybatis框架和Hibernate框架又有什么异同呢? 这个问题在我 ...

  2. ORTP库API使用入门

    一.简介 ORTP是一个支持RTP以及RFC3550协议的库,有如下的特性: (1)使用C语言编写,可以工作于windows, Linux, 以及 Unix平台 (2)实现了RFC3550协议,提供简 ...

  3. UVA11922--Permutation Transformer (伸展树Splay)

    题意:m条操作指令,对于指令 a  b 表示取出第a~b个元素,翻转后添加到排列的尾部. 水题卡了一个小时,一直过不了样例.  原来是 dfs输出的时候 忘记向下传递标记了. #include < ...

  4. Abstract Methods and Classes

    阅读了Java的官方Doc,在此总结如下. Abstract Class & Method In jave, "abstract" can be a modifier to ...

  5. 【译】typeof null的前世今生

        更新时间2013-11-05:为了更好的解释为什么typeof null的结果是object,我看了一下C代码的实现(译者注:Javascript源码).       在Javascript语 ...

  6. Quartz集成springMVC 的方案二(持久化任务、集群和分布式)

    Quartz是一个开放源码项目,专注于任务调度器,提供了极为广泛的特性如持久化任务,集群和分布式任务等. Quartz核心是调度器,还采用多线程管理. 1.持久化任务:当应用程序停止运行时,所有调度信 ...

  7. Python一日一练05----怒刷点击量

    功能 自己主动获取CSDN文章列表,并对每篇文章添加点击量. 源代码 import urllib.request import re import time import random from bs ...

  8. ncsim仿真VHDL

    ncsim仿真VHDL 1.文件列表 ctrl.vhd design_io.vhd tb.vhd compile.nc simulate.nc ./shm/shmtb.tcl 2. Compile你的 ...

  9. VMware SphereESXi上传系统镜像

    VMware SphereESXi上传系统镜像 打开右侧[摘要]选项卡 在[资源]中选择存储器中的存储,右键[浏览数据库存储] 选择工具栏[创建文件夹]图标,命名后保存 这样随后找到存储设备,浏览刚才 ...

  10. Geodatabase - 创建要素类.

    在NET中,会遇到以“_2”结尾的属性,这些属性是可写的. 以下代码在已有工作空间下,创建一个新的点要素类: //例如,personalDBPath=@"G:\doc\gis\1.400\d ...