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. JVM老年代和新生代的比例

    在 Java 中,堆被划分成两个不同的区域:新生代 ( Young ).老年代 ( Old ).新生代 ( Young ) 又被划分为三个区域:Eden.From Survivor.To Surviv ...

  2. CSS属性组-动画、转换、渐变

    一.动画 animation动画属性是一个简写属性,用于设置六个动画属性 aninmation-name动画名称,被调用 animation-duration完成动画需要的持续时间 animation ...

  3. HBase 入门

    使用条件: 海量数据百亿级的行 百万列,  准实时查询 使用场景:  比如金融,交通,电商,移动等 特点: 1:

  4. System.net.mail 使用ssl发送邮件失败

    我采用了.net 的自带组件System.Net.Mail发送邮件,主要是在客户注册网站成功的时候发条欢迎邮件,最近邮件无法发送了,看了下腾讯smtp邮件配置,所有的邮件发送都换成ssl了,之前用的是 ...

  5. 更改html代码后网页不更新

    写了一个非常简单的 html 页面,只有简单的跳转功能,但是在 Eclipse 下更改代码后用 chrome 浏览器打开时还是显示原来的网页.开始我以为是网页有错误或者有不规范的地方,因为我编写的是 ...

  6. P、NP、NPC和NP-Hard相关概念的图形和解释

    P.NP.NPC和NP-Hard相关概念的图形和解释 http://blog.csdn.net/huang1024rui/article/details/49154507 一.相关概念 P: 能在多项 ...

  7. C++17尝鲜:结构化绑定声明(Structured Binding Declaration)

    结构化绑定声明 结构化绑定声明,是指在一次声明中同时引入多个变量,同时绑定初始化表达式的各个子对象的语法形式. 结构化绑定声明使用auto来声明多个变量,所有变量都必须用中括号括起来. cv-auto ...

  8. java-学习8

    方法的声明及使用 public class function { public static void main(String[] args) { printInfo();//调用printInfo( ...

  9. web访问命令行

    https://github.com/yudai/gotty go get github.com/yudai/gotty gotty -p 8000 -w kubectl exec -it mysql ...

  10. Java的学习03

    今天依然记录一下,学习情况,可以看到自己每一天都在进步. import java.text.DateFormat; import java.text.ParseException; import ja ...