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> ...
随机推荐
- PHPExcel在TP下使用
第一:你要去PHPExcel官网下载,然后放到网站的Vendor文件夹下面.当然这是为了好管理和导入.你放在其他位置也没有关系. 第二:当然是在你需要的地方写代码.我只写样例,你看懂了就可以灵活的使用 ...
- 揭开牙病之谜 与牙医说再见<转>
原贴地址:https://www.douban.com/group/topic/44383918/ -------------------------------------------------- ...
- Xcode 新建bundle id不同的且app图标也不同的新的target的步骤
方法一: duplicate一个target 修改target配置文件中的bundle id,app icon图标文件位置(必要时重命名app icon文件名),plist文件位置,entitleme ...
- Socket buffer 调优相关
http://www.man7.org/linux/man-pages/man7/tcp.7.html The maximum sizes for socket buffers declared vi ...
- js 引入外部文件之 script 标签
在我的理解看来,html 就是一个单纯的管显示问题,js就是单纯的管动作问题,css就是单纯的管布局问题,这三个构成了一个网页 在HTML中,经常会用到引入js 文件. 引入js的方法很简单: 1. ...
- Android RxJava 2 的用法 just 、from、map、subscribe、flatmap、Flowable、Function、Consumer ...【转】
先简单说说RxJava的用途与价值 原文出处:Android RxJava 2 的用法 用途: 异步 (也就是开线程跳转) 价值: 面对复杂的逻辑,它依然 简洁 ,代码 易读 RxJava2 与 Rx ...
- Android进阶AIDL - 2018年4月14日
参考:慕课网 --- 最后三集.Android开发艺术探索 1.在AS中创建aidl文件后,要编译一下才会在gen下生成debug文件: 2.AIDL 不支持short类型,常用的数据类型: 3.AI ...
- 【原】Ubuntu virtual terminal
CTRL+ALT+F1 ~ F6 six virtual terminal ALT-F7 return to graphic desktop
- ubuntu14.04后安装win10记录
1首先修改启动引导顺序,从U盘启动, 2自动安装,产生一个问题,gpt分区无法安装,解决方法,感谢https://jingyan.baidu.com/article/08b6a591c82df414a ...
- C# WCF初识
原文:http://www.cnblogs.com/artech/archive/2007/02/26/656901.html 方式1: 需引用 System.ServiceModel namespa ...