Codeforces Beta Round #63 (Div. 2)
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)的更多相关文章
- codeforces水题100道 第九题 Codeforces Beta Round #63 (Div. 2) Young Physicist (math)
题目链接:http://www.codeforces.com/problemset/problem/69/A题意:给你n个三维空间矢量,求这n个矢量的矢量和是否为零.C++代码: #include & ...
- Codeforces Beta Round #59 (Div. 2)
Codeforces Beta Round #59 (Div. 2) http://codeforces.com/contest/63 A #include<bits/stdc++.h> ...
- Codeforces Beta Round #80 (Div. 2 Only)【ABCD】
Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...
- Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】
Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...
- Codeforces Beta Round #79 (Div. 2 Only)
Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...
- Codeforces Beta Round #77 (Div. 2 Only)
Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...
- Codeforces Beta Round #76 (Div. 2 Only)
Codeforces Beta Round #76 (Div. 2 Only) http://codeforces.com/contest/94 A #include<bits/stdc++.h ...
- Codeforces Beta Round #75 (Div. 2 Only)
Codeforces Beta Round #75 (Div. 2 Only) http://codeforces.com/contest/92 A #include<iostream> ...
- Codeforces Beta Round #74 (Div. 2 Only)
Codeforces Beta Round #74 (Div. 2 Only) http://codeforces.com/contest/90 A #include<iostream> ...
随机推荐
- hadoop配置2.6.1 centos7
上传文件(分发)的三种方式: 1.本地: -file 的模式,上传一些小的文件. 例如: -file ./test INPUT_FILE_PATH_1="/The_Man_of_Proper ...
- const 关键字总结
int a; const int* p = &a; == int const * p = &a; 表示通过p不能修改a的值. const int a; int *p = &a ...
- Zookeeper 3、Zookeeper工作原理(转)
1.Zookeeper的角色 » 领导者(leader),负责进行投票的发起和决议,更新系统状态 » 学习者(learner),包括跟随者(follower)和观察者(observer),follow ...
- C语言复习:内存模型1
数据类型本质分析 数据类型概念 "类型"是对数据的抽象; 类型相同的数据有相同的表现形式/存储格式以及相关的操作; 程序中使用的所有数据都必定属于某一种数据类型; 数据类型本质思考 ...
- mysql主从复制搭建中几种log和pos详解
一.主从原理 Replication 线程 Mysql的 Replication 是一个异步的复制过程,从一个 Mysql instace(我们称之为 Master)复制到另一个 Mysql in ...
- ADO数据库操作方式
微软公司的ADO (ActiveX Data Objects) 是一个用于存取数据源的COM组件.它提供了编程语言和统一数据访问方式OLE DB的一个中间层.允许开发人员编写访问数据的代码而不用关心数 ...
- 【x】 PAT/BasicLevel_C++/1002. 写出这个数 (20).cpp
C++中的to_string()函数[C++11支持] - Bravo Yeung-羊较瘦之自留地 - CSDN博客https://blog.csdn.net/lzuacm/article/detai ...
- Android内存优化相关
Android的内存管理方式 Android系统内存分配与回收方式 一个APP通常就是一个进程对应一个虚拟机 GC只在Heap剩余空间不够时才去垃圾回收 GC触发时,所有线程都会被暂停!!! APP内 ...
- 无法加载ISAPI 筛选器 当前配置只支持加载为 AMD64 处理器体系结构创建的映像
无法加载ISAPI 筛选器 当前配置只支持加载为 AMD64 处理器体系结构创建的映像 2011-11-9 0:18:49来源:本站原创作者:清晨320我要评论(0) 今天服务器的伪静态死活加载不上去 ...
- C#中属性和字段的区别
属性和字段的区别 在C#中,我们可以非常自由的.毫无限制的访问公有字段,但在一些场合中,我们可能希望限制只能给字段赋于某个范围的值.或是要求字段只能读或只能写,或是在改变字段时能改变对象的其他一些状态 ...