题目地址: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. ASIHTTPRequest中的DELETE、PUT、GET、POST请求实例-备用

    感谢分享 //  ASIFormDataRequestTests.m //  Part of ASIHTTPRequest -> http://allseeing-i.com/ASIHTTPRe ...

  2. TVS和一般的稳压二极管有什么区别

    电压及电流的瞬态干扰是造成电子电路及设备损坏的主要原因,常给人们带来无法估量的损失.这些干扰通常来自于电力设备的起停操作.交流电网的不稳定.雷击干扰及静电放电等,瞬态干扰几乎无处不在.无时不有,使人感 ...

  3. tyvj1039忠诚2

    描述 Description 老管家是一个聪明能干的人.他为财主工作了整整10年,财主为了让自已账目更加清楚.要求管家每天记k次账,由于管家聪明能干,因而管家总是让财主十分满意.但是由于一些人的挑拨, ...

  4. c#类和结构体的关系

    原文地址:http://www.dnbcw.com/biancheng/c/fvhc81798.html 简介:这是c#类和结构体的关系的详细页面,介绍了和c/c++,有关的知识,谢谢大家的观看!要查 ...

  5. C与C++中的const

    同样,有下面一段代码: #include <iostream> using namespace std; int main() { ; int *j = (int *) &i; * ...

  6. openStack kilo 手动Manual部署随笔记录

    一 ,基于neutron网络资源主机(控制节点,网络节点,计算节点)网络规划配置 1, controller.cc 节点 网络配置截图

  7. Oracle百问百答(四)

    Oracle百问百答(四) 31.怎样查看某用户下的表? select table_name from all_tables where owner=upper('jhemr'); 32.怎样查看某用 ...

  8. Javascript: 截取字符串多出来并用省略号[...]显示

    /背景知识/ substring 方法用于提取字符串中介于两个指定下标之间的字符 substring(start,end) 开始和结束的位置,从零开始的索引 参数描述 start 必需.一个非负的整数 ...

  9. Android BLE开发之Android手机与BLE终端通信

    本文来自http://blog.csdn.net/hellogv/ ,引用必须注明出处! 近期穿戴设备发展得非常火.把相关技术也带旺了,当中一项是BLE(Bluetooth Low Energy).B ...

  10. 如何实现带照片缩略图的Listview

    ackage com.demo; import java.util.ArrayList; import android.app.Activity; import android.content.Con ...