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. linux驱动开发第二步 驱动模块传参(module_param函数使用)

    在驱动的模块中声明一下你要传递的参数名称,类型和权限 module_param(变量的名称,类型,权限); 先上例子 #include <linux/init.h> #include &l ...

  2. react-native android 权限问题

    初入reactNative 的一个坑 我是用的真机测试,没用安卓模拟器 第一次在安卓上打开应用,提示权限问题: Overlay permissions needs to be granted in o ...

  3. Linux下源码编译安装PostgreSQL数据库

    我使用的Postgres的源码版本为 postgresql-9.3.5.系统为 CentOS6.5 ,是64位. 下载以后直接阅读其中的 README然后阅读其中的INSTALL,按照其中将的步骤做就 ...

  4. table布局与div布局

      DIV与TABLE本身并不存在什么优缺点,所谓web标准只是推荐的是正确的使用标签,好比说:DIV用于布局,而TABLE则本来就是转二维数据的.让TABLE做该做的事,并不是说页面里不出现TABL ...

  5. 尚硅谷springboot学习21-web开发-处理静态资源

    SpringBoot对静态资源的映射规则 @ConfigurationProperties(prefix = "spring.resources", ignoreUnknownFi ...

  6. laravel视图$errors为空

    最近用laravel5.2的validator时,完全参考手册操作,结果控制器$validator->errors()->all()正常显示错误信息,$validator->fail ...

  7. redis集群报错:(error) MOVED 11469 192.168.163.249:7002

    应该是你没有启动集群模式(即缺少了那个"-c"): redis-cli -c -h yourhost -p yourpost

  8. 四则运算3+PSP

    题目要求: 1.要求在第二次实验(四则运算2)的基础上加上其他功能. 2.要求能够在每个运算式打印出来后,用户能够进行输入计算的答案,并且程序进行判断给出用户输入的答案的正确性. 3.要求实现四则混合 ...

  9. cap文件的格式说明

    前面24个字节是.cap文件的文件头. 头信息对应的结构体为:struct pcap_file_header {  bpf_u_int32 magic;  u_short version_major; ...

  10. 传输层——TCP报文头介绍

    16位源端口号 16位目的端口号 32位序列号 32位确认序列号 4位头部长度 保留6位 U R G A C K P S H R S T S Y N F I N 16位窗口大小 16位检验和 16位紧 ...