题目地址: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. Chrome下的语音控制框架MyVoix.js使用篇(一)

    日前因工作需求,着手研究了语音识别技术,发现github上有网友发布了一款叫做voix.js的javascript框架.在拜读voix.js的源码后发现了不少问题,于是自己写了一款语音识别框架MyVo ...

  2. 自制单片机之六……串行I2C总线E2PROM AT24CXXX的应用

    这一篇介绍I2C存储器的使用.主要是介绍AT24CXX系列器件,它分为两类,主要是通过被存储容量地址来分的,一类是AT24C02-AT24C16,它的存储容量从256字节到2048字节.另一类是AT2 ...

  3. Qt编程之在QGraphics scene中使用图片

    http://stackoverflow.com/questions/5960074/qimage-in-a-qgraphics-scene http://stackoverflow.com/ques ...

  4. Android中实现全屏、无标题栏的两种办法(另附Android系统自带样式的解释)

    在进行UI设计时,我们经常需要将屏幕设置成无标题栏或者全屏.要实现起来也非常简单,主要有两种方法:配置xml文件和编写代码设置. 1.在xml文件中进行配置 在项目的清单文件AndroidManife ...

  5. bzoj 1196

    http://www.lydsy.com/JudgeOnline/problem.php?id=1196 二分+并查集 一共有2*M条路径,我们首先将这2*M条路径按费用排序. 然后二分最大费用的公路 ...

  6. Android studio无法更新 提示网络连接失败

    Android studio 更新时,提示网络问题 “Connection failed. Please check your network connection and try again” 在默 ...

  7. mysql 中文乱码的解决方法

    添加或修改my.ini 配置文件,设置编码字符为utf8 ,默认为latin1,见红色字体 [mysql]# 设置mysql客户端默认字符集default-character-set=utf8 [my ...

  8. vuex 模块

    今天,在我编写系统中一个模块功能的时候,由于我使用vuex存储数据的状态,并分模块存储.我是这样在存储文件中定义state,getters,actions,mutations的,我打算在不同模块文件都 ...

  9. [转]使用Composer管理PHP依赖关系

    简介 现在软件规模越来越大,PHP项目的开发模式和许多年前已经有了很大变化.记得初学PHP那会儿,boblog是一个很好的例子,几乎可以代表 PHP项目的开发模式.当时PHP 5.x以上的版本刚开始流 ...

  10. 什么是系统平均负载(Load average)

    一.什么是系统平均负载(Load average)? 在Linux系统中,uptime.w.top等命令都会有系统平均负载load average的输出,那么什么是系统平均负载呢? Load Aver ...