题目地址: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. list排序成员函数对string对象与char*对象排序的差别

    对list容器中的对象排序,不能使用sort()算法,只能采用其自身的排序函数sort().因为,算法sort()只支持随机存取的容器的排序,如vector等. 对基本数据对象list排序:成员函数s ...

  2. EBS导出键弹性域

    select gl_flexfields_pkg.get_description_sql(gcc.chart_of_accounts_id, 1, gcc.segment1) || '-' || gl ...

  3. HDU4514(非连通图的环判断与图中最长链)

    题目:设计风景线 题意:给定一个无向图,图可能是非连通的,如果图中存在环,就输出YES,否则就输出图中最长链的长度. 分析:首先我们得考虑这是一个无向图,而且有可能是非连通的,那么就不能直接像求树那样 ...

  4. c语言指向结构体的指针作为函数参数

    注意 这里包括形参和实参 struct dangdangtest { ]; int num; }; void change(int num)//值传递 新建一个变量接受传递的值 { num = ; } ...

  5. js基础例子

    创建变量 var obj=value; 其中obj是变量名; value表示可能是数字,数组,函数之类的 多变量进行计算 var a1=200,b1='hello',c1=400; var d1=c1 ...

  6. Js获取元素样式值(getComputedStyle&currentStyle)兼容性解决方案

    因为:style(document.getElementById(id).style.XXX)只能获取元素的内联样式,内部样式和外部样式使用style是获取不到的. 一般js获取内部样式和外部样式使用 ...

  7. 浏览器内核Trident/Gecko/WebKit/Presto

    “浏览器内核”主要指渲染引擎(Rendering Engine),负责解析网页语法(如HTML.JavaScript)并渲染.展示网页.因此,所谓的浏览器内核通常也就是指浏览器所采用的渲染引擎, 渲染 ...

  8. 信息熵(Entropy)究竟是用来衡量什么的?

    信息熵(Entropy)究竟是用来衡量什么的? ——与Philip ZHANG商榷 思明 Philip ZHANG先生在反驳彭小明的时候,提出一个观点,他说:“ 就语言文 字来说,总体效率不是用民族主 ...

  9. [Redux] Generating Containers with connect() from React Redux (VisibleTodoList)

    Learn how to use the that comes with React Redux instead of the hand-rolled implementation from the ...

  10. Java_.jar .war .ear 详解

      .jar 全称:                     java archive: 包含:                     class.properties文件,是文件封装的最小单元: ...