暑期热身赛

BAPC 2014
The 2014 Benelux Algorithm Programming Contest
 
B Button Bashing
 #include<stdio.h>
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string.h>
#include<queue>
using namespace std; const int inf=;
int a[];
int vis[];
int tim,step,n,m;
struct Node
{
int step,time;
}; void bfs()
{
queue <Node> q;
Node s; s.step=s.time=;
vis[]=;
q.push(s);
while(!q.empty())
{
Node now=q.front();
q.pop();
if(now.time>=m)
{
int temp=now.time-m;
if(temp==tim)
{
step=min(now.step,step);
}
if(temp<tim)
{
tim=temp;
step=now.step;
}
}
for(int i=; i<=n; i++)
{
Node next;
next.step=now.step+;
next.time=now.time+a[i];
if(next.time>)
{
next.time=;
}
if(next.time> && !vis[next.time])
{
vis[next.time]=;
q.push(next);
}
}
}
} int main()
{ int t;
cin>>t;
while(t--)
{
cin>>n>>m;
for(int i=; i<=; i++)
vis[i]=;
for(int i=; i<=n; i++)
{
cin>>a[i];
}
tim=step=inf;
if(m==)
{
printf("0 0\n");
//continue;
}
else
{
bfs();
printf("%d %d\n",step,tim);
}
}
return ;
}
 #include<iostream>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<string.h>
#define MAX 0x7f7f7f7f
#define N 100004
using namespace std;
typedef long long LL;
int cas,cass;
int n,m,lll,ans;
struct xxx
{
int x,y,z;
} a[N];
int t[N<<];
bool cmp(xxx aa,xxx bb)
{
return aa.x<bb.x;
}
void change(int l,int r,int x,int c,int k)
{
if(l>r || x<l || x>r)return;
if(l==r)
{
t[k]=c;
return;
}
change(l,(l+r)>>,x,c,k+k);
change((l+r)/+,r,x,c,k+k+);
t[k]=min(t[k+k],t[k+k+]);
}
int query(int l,int r,int a,int b,int k)
{
if(l>r || l>b || r<a)return MAX;
if(a<=l && r<=b)return t[k];
int x1=query(l,(l+r)>>,a,b,k+k),x2=query((l+r)/+,r,a,b,k+k+);
return t[k]=min(x1,x2);
}
int main()
{
int i,j,k;
for(scanf("%d",&cas); cas; cas--) {
ans=;
memset(t,0x7f,sizeof t);
scanf("%d",&n);
for(i=; i<=n; i++)
scanf("%d%d%d",&a[i].y,&a[i].z,&a[i].x);
sort(a+,a++n,cmp);
change(,n,a[].y,a[].z,);
for(i=; i<=n; i++)
{
j=query(,n,,a[i].y,);
if(j>a[i].z)ans++;
change(,n,a[i].y,a[i].z,);
}
printf("%d\n",ans);
}
return ;
}
 #include<stdio.h>
#include<bits/stdc++.h>
#include<math.h>
#include<algorithm>
#include<string.h>
using namespace std; int main()
{
int t,n;
double a,b,c;
cin>>t;
while(t--)
{
cin>>n;
int ans,shuchu;
ans=;
double maxn=;
while(n--)
{ cin>>a>>b>>c;
double q=(double)(c+(b*b)/(*a));
//cout<<q<<" ";
ans++;
if(q>maxn)
{
shuchu=ans;
}
maxn=max(q,maxn); }
cout<<shuchu<<endl;
}
return ;
}
 #include<iostream>
#include<cstdio>
#include<cmath>
using namespace std; int main()
{
int t,n,x,y;
int f[];
f[]=;
f[]=;
int i=;
for(i=; i<=; i++)
{
f[i]=f[i-]+f[i-];
} cin>>t;
while(t--)
{
cin>>n;
bool bb=;
for(i=; i>&&bb; i--)
{
for(int ty=; ty<=; ty++)
{
if(ty*f[i]+f[i-]>n)
{
break;
}
else if((n-ty*f[i])%f[i-]== &&(n-ty*f[i])/f[i-]<=ty)
{
y=ty;
x=(n-ty*f[i])/f[i-];
bb=;
break;
} } }
cout<<x<<" "<<y<<endl;
}
return ;
}
 #include<stdio.h>
#include<algorithm>
#include<math.h>
#include<queue>
#include<string.h>
#define Max(a,b) (a>b?a:b)
#include<bits/stdc++.h>
using namespace std; const int maxn=1e6;
struct node
{
int x,y,p;
node(int x=,int y=,int p=):x(x),y(y),p(p) {}
};
char s[maxn],mp[][]; int main()
{
int t,r,c;
cin>>t;
cout<<t<<endl; while(t--)
{
cin>>s;
memset(mp,'#',sizeof mp);
mp[][]='.';
int minx=,maxx=,miny=,maxy=;
node pi=node(,,);
for(int i=; i<strlen(s); i++)
{
if(s[i]=='F')
{
if(pi.p==)
pi.y+=;
if(pi.p==)
pi.x-=;
if(pi.p==)
pi.y-=;
if(pi.p==)
pi.x+=;
mp[pi.x][pi.y]='.';
}
else if(s[i]=='B')
{
if(pi.p==)
pi.y-=;
if(pi.p==)
pi.x+=;
if(pi.p==)
pi.y+=;
if(pi.p==)
pi.x-=;
mp[pi.x][pi.y]='.';
pi.p=(pi.p+)%;
}
else if(s[i]=='L')
{
if(pi.p==)
pi.x-=;
if(pi.p==)
pi.y-=;
if(pi.p==)
pi.x+=;
if(pi.p==)
pi.y+=;
mp[pi.x][pi.y]='.';
pi.p=(pi.p+)%;
}
else if(s[i]=='R')
{
if(pi.p==)
pi.x+=;
if(pi.p==)
pi.y+=;
if(pi.p==)
pi.x-=;
if(pi.p==)
pi.y-=;
mp[pi.x][pi.y]='.';
pi.p=(pi.p+)%;
}
minx=min(minx,pi.x);
maxx=max(maxx,pi.x);
miny=min(miny,pi.y);
maxy=max(maxy,pi.y); }
cout<<(maxx-minx+)<<' '<<(maxy-miny+)<<endl;
//cout<<maxy<<miny;
for(int i=minx-; i<=maxx+; i++)
{
for(int j=; j<=maxy+; j++)
{
printf("%c",mp[i][j]);
}
printf("\n");
} }
return ;
}

ACM 第十七天的更多相关文章

  1. 第十七周自由练习项目——acm 学生最高最低成绩

    /* *程序的版权和版本号声明部分: *Copyright(c)2014,烟台大学计算机学院学生 *All rights reserved. *文件名:acm 学生最高与最低成绩 *作者:刘中林 *完 ...

  2. ACM入门步骤(一)

    一般的入门顺序: 0. C语言的基本语法(或者直接开C++也行,当一个java选手可能会更受欢迎,并且以后工作好找,但是难度有点大),[参考书籍:刘汝佳的<算法竞赛入门经典>,C++入门可 ...

  3. 「kuangbin带你飞」专题十七 AC自动机

    layout: post title: 「kuangbin带你飞」专题十七 AC自动机 author: "luowentaoaa" catalog: true tags: - ku ...

  4. SCNU ACM 2016新生赛决赛 解题报告

    新生初赛题目.解题思路.参考代码一览 A. 拒绝虐狗 Problem Description CZJ 去排队打饭的时候看到前面有几对情侣秀恩爱,作为单身狗的 CZJ 表示很难受. 现在给出一个字符串代 ...

  5. 我的MYSQL学习心得(十七) 复制

    我的MYSQL学习心得(十七) 复制 我的MYSQL学习心得(一) 简单语法 我的MYSQL学习心得(二) 数据类型宽度 我的MYSQL学习心得(三) 查看字段长度 我的MYSQL学习心得(四) 数据 ...

  6. SCNU ACM 2016新生赛初赛 解题报告

    新生初赛题目.解题思路.参考代码一览 1001. 无聊的日常 Problem Description 两位小朋友小A和小B无聊时玩了个游戏,在限定时间内说出一排数字,那边说出的数大就赢,你的工作是帮他 ...

  7. acm结束了

    最后一场比赛打完了.之前为了记录一些题目,开了这个博客,现在结束了acm,这个博客之后也不再更新了. 大家继续加油!

  8. 关于ACM的总结

    看了不少大神的退役帖,今天终于要本弱装一波逼祭奠一下我关于ACM的回忆. 从大二上开始接触到大三下结束,接近两年的时间,对于大神们来说两年的确算不上时间,然而对于本弱来说就是大学的一半时光.大一的懵懂 ...

  9. 第一届山东省ACM——Phone Number(java)

    Description We know that if a phone number A is another phone number B’s prefix, B is not able to be ...

随机推荐

  1. swoole学习(二)----搭建server和client

    1.搭建server 1.1搭建server.php 1.搭建websocket服务器,首先建立 server.php 文件, <?php $server = new swoole_websoc ...

  2. 20190112-自定义实现字符串的操作方法,如strip,upper,title,ljust,center,zfill,find,rfind等

    1:自定义实现strip()Python strip() 方法用于移除字符串头尾指定的字符(默认为空格或换行符)或字符序列算法:strip()仅移除首尾的指定字符,不能移除中间的先从首部开始移除 de ...

  3. Python(1-8天总结)

    day1:变量:把程序运行过程中产生的中间值.暂时存储起来.方便后面的程序调用.变量命名规范:常量:所有字母大写注释:数据类型: 1. int 整数 2. str 字符串. 不会用字符串保存大量的数据 ...

  4. ubuntu 杂记

    修改/home下中文目录 网易云sudo解决 https://jingyan.baidu.com/article/1e5468f956a15c484861b770.html 字体     https: ...

  5. 状压搜索 洛谷T47092 作业

    TYM 有 nn 本作业,编号为 1,\dots,n1,…,n. 由于 \mathrm{TYM}TYM 很喜欢偷懒,而且不喜欢消耗脑细胞,所以他选择跳着完成这 nn 本作业.此外,如果将做作业的顺序转 ...

  6. 20145209刘一阳《网络对抗》实验五:MSF基础应用

    20145209刘一阳<网络对抗>实验五:MSF基础应用 主动攻击 首先,我们需要弄一个xp sp3 English系统的虚拟机,然后本次主动攻击就在我们kali和xp之间来完成. 然后我 ...

  7. 北京Uber优步司机奖励政策(12月27日)

    滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...

  8. Python:numpy中的tile函数

    在学习机器学习实教程时,实现KNN算法的代码中用到了numpy的tile函数,因此对该函数进行了一番学习: tile函数位于python模块 numpy.lib.shape_base中,他的功能是重复 ...

  9. Jsp刷新分页模板,很全

      1.用来实现上一页下一页,我直接写到查询页面上 <%--page的分页--%> <style type="text/css"> a { color: # ...

  10. DSP5509的ADC实验

    1. 本次使用esay5509开发板,具体做这个板子叫做大道科技. 2. 5509有2个ADC的输入引脚,就是2个采集通道 3. 看下ADC的寄存器 4. 看下代码中怎么引用ADC的寄存器的,这种写法 ...