Codeforces Beta Round #63 (Div. 2)

http://codeforces.com/contest/69

A

 #include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define pb push_back
#define eb emplace_back
#define maxn 1000006
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef unsigned long long ull; int n;
struct sair{
int x,y,z;
}a[]; int main(){
#ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
cin>>n;
for(int i=;i<=n;i++){
cin>>a[i].x>>a[i].y>>a[i].z;
}
int aa=,bb=,cc=;
for(int i=;i<=n;i++){
aa+=a[i].x;
bb+=a[i].y;
cc+=a[i].z;
}
if(aa||bb||cc) cout<<"NO"<<endl;
else cout<<"YES"<<endl;
}

B

 #include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define pb push_back
#define eb emplace_back
#define maxn 1000006
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef unsigned long long ull; int n,m;
int k[],p[]; int main(){
#ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
int l,r,t,c;
int ans=;
cin>>n>>m;
for(int i=;i<m;i++){
cin>>l>>r>>t>>c;
for(int j=l;j<=r;j++){
if(t<k[j]||!k[j]){
k[j]=t;
ans-=p[j];
p[j]=c;
ans+=p[j];
}
}
}
cout<<ans<<endl;
}

C

模拟

 #include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define pb push_back
#define eb emplace_back
#define maxn 1000006
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef unsigned long long ull; char name1[][],name2[][];
int with[][],have[][],n;
int g[][];
char tname[];
char s[];
int Find(char *name)
{
for (int i=;i<n;i++)
if (strcmp(name,name1[i])==) return i;
return ;
}
struct sair{
char name[];
int num;
};
sair p[];
bool cmp(sair x,sair y)
{
return strcmp(x.name,y.name)<;
} int main(){
#ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
int k,m,t;
scanf("%d%d%d%d",&k,&n,&m,&t);
for (int i=;i<n;i++)
scanf("%s",name1[i]);
getchar();
memset(g,,sizeof(g));
for (int ii=;ii<m;ii++)
{
gets(s);
int len=strlen(s);
int cnt=,i=;
for (i=;i<len&&s[i]!=':';i++)
name2[ii][cnt++]=s[i];
name2[ii][cnt++]=;
i+=;
while (i<len)
{
cnt=;
for (;s[i]!=' ';i++)
tname[cnt++]=s[i];
tname[cnt]=;
int id=Find(tname);
i++;
int num=;
for (;s[i]!=&&s[i]!=',';i++)
num=num*+s[i]-'';
g[ii][id]=num;
i+=;
}
}
memset(have,,sizeof(have));
memset(with,,sizeof(with));
for (int i=;i<t;i++)
{
int tnum;
scanf("%d",&tnum);
scanf("%s",tname);
int id=Find(tname);
have[tnum][id]++;
for (int j=;j<m;j++)
{
bool tfind=true;
for (int k=;k<n;k++)
if (have[tnum][k]<g[j][k]) tfind=false;
if (tfind)
{
for (int k=;k<n;k++)
have[tnum][k]-=g[j][k];
with[tnum][j]++;
}
}
}
for (int i=;i<=k;i++)
{
int cnt=;
for (int j=;j<n;j++)
if (have[i][j]!=)
{
p[cnt].num=have[i][j];
strcpy(p[cnt++].name,name1[j]);
}
for (int j=;j<m;j++)
if (with[i][j]!=)
{
p[cnt].num=with[i][j];
strcpy(p[cnt++].name,name2[j]);
}
sort(p,p+cnt,cmp);
printf("%d\n",cnt);
for (int j=;j<cnt;j++)
printf("%s %d\n",p[j].name,p[j].num);
}
}

D

记忆化搜索的博弈,和前天的E题很像

题意:给个初始点,然后两个人轮流移动一段距离,当点和原点的距离大于d时失败。题目中的点可以移动到y=x的对称点这条件没用,因为一个人使用了这个条件,另一个人也可以使用它使点回到刚刚的位置

 #include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define pb push_back
#define eb emplace_back
#define maxn 1000006
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef unsigned long long ull; int d,n;
struct sair{
int x,y;
}a[]; int book[][]; bool dist(int a,int b){
return (a-)*(a-)+(b-)*(b-) <= d*d;
} int dfs(int x,int y){
int xx,yy;
if(book[x][y]) return book[x][y];
for(int i=;i<=n;i++){
xx=x+a[i].x;
yy=y+a[i].y;
if(dist(xx,yy)){
if(==dfs(xx,yy)){
return book[x][y]=;
}
}
}
return book[x][y]=;
} int main(){
#ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
int x,y;
cin>>x>>y>>n>>d;
for(int i=;i<=n;i++){
cin>>a[i].x>>a[i].y;
}
if(dfs(x+,y+)==) cout<<"Anton"<<endl;
else cout<<"Dasha"<<endl; }

E

题意:找出在一定区间内只出现过一次的最大的数

思路:建两个map,一个记录数的个数,另一个记录当前个数为1的值即可

 #include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define pb push_back
#define eb emplace_back
#define maxn 1000006
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef unsigned long long ull; int n,k;
int a[];
map<int,int>mp;
map<int,int>book;
map<int,int>::iterator it;
map<int,int>::reverse_iterator rit; int main(){
#ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
cin>>n>>k;
for(int i=;i<=n;i++) cin>>a[i];
for(int i=;i<=k;i++){
mp[a[i]]++;
if(mp[a[i]]==){
book.erase(book.find(a[i]));
}
else if(mp[a[i]]==){
book[a[i]]=;
}
}
if(book.size()==){
cout<<"Nothing"<<endl;
}
else{
rit=book.rbegin();
cout<<rit->first<<endl;
}
for(int i=k+;i<=n;i++){
mp[a[i-k]]--;
if(mp[a[i-k]]==) book.erase(book.find(a[i-k]));
else if(mp[a[i-k]]==) book[a[i-k]]=;
mp[a[i]]++;
if(mp[a[i]]==) book[a[i]]=;
else if(mp[a[i]]==)book.erase(book.find(a[i]));
if(book.size()==){
cout<<"Nothing"<<endl;
}
else{
rit=book.rbegin();
cout<<rit->first<<endl;
}
} }

Codeforces Beta Round #63 (Div. 2)的更多相关文章

  1. codeforces水题100道 第九题 Codeforces Beta Round #63 (Div. 2) Young Physicist (math)

    题目链接:http://www.codeforces.com/problemset/problem/69/A题意:给你n个三维空间矢量,求这n个矢量的矢量和是否为零.C++代码: #include & ...

  2. Codeforces Beta Round #59 (Div. 2)

    Codeforces Beta Round #59 (Div. 2) http://codeforces.com/contest/63 A #include<bits/stdc++.h> ...

  3. Codeforces Beta Round #80 (Div. 2 Only)【ABCD】

    Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...

  4. Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】

    Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...

  5. Codeforces Beta Round #79 (Div. 2 Only)

    Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...

  6. Codeforces Beta Round #77 (Div. 2 Only)

    Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...

  7. Codeforces Beta Round #76 (Div. 2 Only)

    Codeforces Beta Round #76 (Div. 2 Only) http://codeforces.com/contest/94 A #include<bits/stdc++.h ...

  8. Codeforces Beta Round #75 (Div. 2 Only)

    Codeforces Beta Round #75 (Div. 2 Only) http://codeforces.com/contest/92 A #include<iostream> ...

  9. Codeforces Beta Round #74 (Div. 2 Only)

    Codeforces Beta Round #74 (Div. 2 Only) http://codeforces.com/contest/90 A #include<iostream> ...

随机推荐

  1. centos 7 端口

    查看端口是否占用 netstat -tlnp|grep 8080 查看已经开放的端口 firewall-cmd --zone=public --list-ports 增加开放端口 firewall-c ...

  2. Linux MySQL 安装、远程访问和密码重置

    安装: yum install mysql yum install mysql-server yum install mysql-devel 设置开机启动: chkconfig -add mysqld ...

  3. 正则表达式——WPF输入控件TextBox 限定输入特定字符

    概念: 正则表达式是对字符串操作的一种逻辑公式, 就是用事先定义好的一些特定字符.及这些特定字符的组合,组成一个“规则字符串”, 这个“规则字符串”用来表达对字符串的一种过滤逻辑. 目的: 给定一个正 ...

  4. python_03 各种运算符

    1.算数运算 2.比较运算 3.赋值运算 4.逻辑运算 先计算括号中表达式 计算顺序:and,or,not在一个表达式中从前到后计算, 若and前一个元素为false则立刻返回为False,不计算后面 ...

  5. Mp4 to Img

    # -*- coding: utf-8 -*- """ Created on Thu May 3 16:51:50 2018 """ # 录 ...

  6. English-英语学习杂志及资料

    [英文原版杂志] >>经济学人 英文原版PDF+双语版+文本音频 超全下载!http://bbs.zhan.com/thread-8443-1-1.html?sid=2004 >&g ...

  7. URL分发(URLConf)

    如果项目中应用太多,都写到顶层的urls.py中,如果个别应用url出问题的话,其他的应用也会受影响,所以我们需要对每个应用下面都写一个urls.py,实现分发 顶层urls.py中写:(属于blog ...

  8. 使用curator框架简单操作zookeeper 学习笔记

    Curator 操作是zookeeper的优秀api(相对于原生api),满足大部分需求.而且是Fluent流式api风格. 参考文献:https://www.jianshu.com/p/70151f ...

  9. docker的完整解决方案2

    这个解决方案很简单 使用docker自带的swarm 首先初始化集群 docker swarm init 然后其余节点加入集群,这个就不说,太简单了 集群初始化后,可以查看下集群状态 docker n ...

  10. indexOf实现引申出来的各种字符串匹配算法

    我们在表单验证时,经常遇到字符串的包含问题,比如说邮件必须包含indexOf.我们现在说一下indexOf.这是es3.1引进的API ,与lastIndexOf是一套的.可以用于字符串与数组中.一些 ...