2016 10.19-10.20 两天  题目by mzx

Day1:

T1:loverfinding

题解:hash

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<ctime>
#include<cmath>
#include<queue>
using namespace std;
#define FILE "loverfinding"
#define pii pair<long long,long long>
#define LL long long
#define up(i,j,n) for(int i=j;i<=n;i++)
#define down(i,n,j) for(int i=n;i>=j;i--)
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define abs(x) ((x)<0?(-(x)):(x))
template<typename T>inline bool chkmax(T &a,T b){return a<b?a=b,true : false;}
template<typename T>inline bool chkmin(T &a,T b){return a>b?a=b,true : false;}
int read(){
int x=;char ch=getchar();bool flag=;
while(ch<''||ch>''){if(ch=='-')flag=;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return flag?-x:x;
}
namespace OI{
void print(int x){printf("%d\n",x);exit();}
int n,x0,y0,xt,yt,cnt=,nx,ny,dx,dy;
int hx[],hy[],step=,mod=;
bool vis[];
bool hash(int x,int y){
int pos=abs((LL)(x+)*%mod*(y+)%mod*%mod*)%mod;
while(vis[pos]&&!(hx[pos]==x&&hy[pos]==y)){
pos+=step;
if(pos>mod)pos-=mod;
}
if(!vis[pos]){
vis[pos]=;hx[pos]=x;hy[pos]=y;return ;
}
return ;
}
void slove(){
n=read(),nx=x0=read(),ny=y0=read(),xt=read(),yt=read();
up(i,,n){
if(nx==xt&&ny==yt)print(cnt);
if(hash(nx,ny))cnt++;
dx=read(),dy=read();
nx+=dx,ny+=dy;
}
printf("SingleDogMZX\n");
}
}
int main(){
freopen(FILE".in","r",stdin);
freopen(FILE".out","w",stdout);
using namespace OI;
slove();
return ;
}

T2:snackstore

题解:floyed

#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
#define FILE "snackstore"
#define up(i,j,n) for(int i=j;i<=n;i++)
template<typename T>inline bool chkmax(T &a,T b){return a<b?a=b,true : false;}
template<typename T>inline bool chkmin(T &a,T b){return a>b?a=b,true : false;}
namespace IO{
char buf[<<],*fs,*ft;
inline char gc(){return (fs==ft&&(ft=(fs=buf)+fread(buf,,<<,stdin),fs==ft))?:*fs++;}
inline int read(){
int x=,ch=gc();
while(ch<''||ch>'')ch=gc();
while(ch>=''&&ch<='')x=(x<<)+(x<<)+ch-'',ch=gc();
return x;
}
}using namespace IO;
namespace OI{
const int maxn=;
const int inf=1000000001LL;
int n,m,Q;
struct node{
int id,v;
bool operator<(const node& b)const{return v<b.v;}
}v[maxn];
int A[maxn],pow[maxn];
int f[maxn][maxn][maxn];
void init(){
n=read(),m=read(),Q=read();
up(i,,n)v[i].v=read(),v[i].id=i;
int x,y,vv;
for(int c=;c<=n;c++)
for(int i=;i<=n;i++)
for(int j=;j<=n;j++)
f[c][i][j]=inf;
for(int i=;i<=n;i++)f[][i][i]=;
up(i,,m){
x=read(),y=read(),vv=read();
if(vv<f[][y][x])f[][x][y]=f[][y][x]=vv;
}
sort(v+,v+n+);
for(int i=;i<=n;i++)A[i]=v[i].id;
for(int i=;i<=n;i++)pow[i]=v[i].v;
for(int c=;c<=n;c++){
memcpy(f[c],f[c-],sizeof(f[c-]));
for(int i=;i<=n;i++)
for(int j=;j<=n;j++)
if(f[c][i][A[c]]+f[c][A[c]][j]<f[c][i][j])
f[c][i][j]=f[c][i][A[c]]+f[c][A[c]][j];
}
for(int c=;c<=n;c++)
for(int i=;i<=n;i++)
sort(f[c][i]+,f[c][i]+n+);
}
int left,right,mid,ans;
inline int find(int c){
left=,right=n;
while(left<=right){
mid=(left+right)>>;
if(c>=pow[mid])ans=mid,left=mid+;
else right=mid-;
}
return ans;
}
inline int Find(int *a,int d){
left=,right=n;
while(left<=right){
mid=(left+right)>>;
if(a[mid]>d)right=mid-;
else left=mid+,ans=mid;
}
return ans;
}
void slove(){
init();
int s,c,d,pos;
up(i,,Q){
s=read(),c=read(),d=read();
printf("%d\n",Find(f[find(c)][s],d)-);
}
return;
}
} int main(){
freopen(FILE".in","r",stdin);
freopen(FILE".out","w",stdout);
using namespace OI;
slove();
return ;
}

T3:有点恶心,暂时搁置

Day2:

T1:three_squirrels

题解:拓扑排序

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<ctime>
#include<cmath>
#include<queue>
using namespace std;
#define FILE "three_squirrels"
#define pii pair<long long,long long>
#define LL long long
#define up(i,j,n) for(int i=j;i<=n;i++)
#define down(i,n,j) for(int i=n;i>=j;i--)
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define abs(x) ((x)<0?(-(x)):(x))
template<typename T>inline bool chkmax(T &a,T b){return a<b?a=b,true : false;}
template<typename T>inline bool chkmin(T &a,T b){return a>b?a=b,true : false;}
int read(){
int x=;char ch=getchar();bool flag=;
while(ch<''||ch>''){if(ch=='-')flag=;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return flag?-x:x;
}
namespace OI{
const int maxn=,mod=;
int f[maxn];
int n;
struct node{
int y,next;
}e[];
int len=,linkk[maxn];
void insert(int x,int y){
e[++len].y=y;
e[len].next=linkk[x];
linkk[x]=len;
}
int dfs(int x){
if(f[x]!=-)return f[x];
f[x]=;
for(int i=linkk[x];i;i=e[i].next)f[x]=(f[x]+dfs(e[i].y))%mod;
return f[x];
}
void slove(){
memset(f,-,sizeof(f));
f[]=;
n=read();int k,x;
up(i,,n){
k=read();
up(j,,k){
x=read();
insert(i,x);
}
}
printf("%d\n",dfs(n));
}
} int main(){
freopen(FILE".in","r",stdin);
freopen(FILE".out","w",stdout);
using namespace OI;
slove();
return ;
}

T2:savemzx

题解:树形动规

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<ctime>
#include<cmath>
#include<queue>
using namespace std;
#define FILE "savemzx"
#define pii pair<long long,long long>
#define LL long long
#define up(i,j,n) for(int i=j;i<=n;i++)
#define down(i,n,j) for(int i=n;i>=j;i--)
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define abs(x) ((x)<0?(-(x)):(x))
template<typename T>inline bool chkmax(T &a,T b){return a<b?a=b,true : false;}
template<typename T>inline bool chkmin(T &a,T b){return a>b?a=b,true : false;}
int read(){
int x=;char ch=getchar();bool flag=;
while(ch<''||ch>''){if(ch=='-')flag=;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return flag?-x:x;
}
namespace OI{
const int maxn=;
const LL inf=10000000000000000LL;
char s[maxn];
int next[maxn],n;
bool vis[maxn];
inline LL squ(int x){return (LL)x*x;}
struct node{
int y,next;
LL v;
}e[maxn<<];
int linkk[maxn],len=;
void insert(int x,int y,LL v){
e[++len].y=y;
e[len].next=linkk[x];
linkk[x]=len;
e[len].v=v;
}
LL w[maxn],maxx[maxn],maxx2[maxn],child[maxn];
int fa[maxn];
LL ans=;
void dfs(int x){
for(int i=linkk[x];i;i=e[i].next){
if(e[i].y==fa[x])continue;
fa[e[i].y]=x;
dfs(e[i].y);
chkmax(ans,e[i].v);
w[e[i].y]+=e[i].v;
if(w[e[i].y]>maxx[x])maxx2[x]=maxx[x],maxx[x]=w[e[i].y];
else if(w[e[i].y]>maxx2[x])maxx2[x]=w[e[i].y];
}
chkmax(ans,maxx[x]+maxx2[x]);
w[x]=maxx[x];
}
void slove(){
scanf("%s",s+);n=strlen(s+);
int j=;next[]=;
insert(,,);insert(,,);
for(int i=;i<=n;i++){
while(s[i]!=s[j+]&&j)j=next[j];
if(s[i]==s[j+])j++;
next[i]=j;
insert(j,i,squ(j-i));
insert(i,j,squ(i-j));
}
dfs();
printf("%lld\n",ans);
return;
}
}
int main(){
freopen(FILE".in","r",stdin);
freopen(FILE".out","w",stdout);
using namespace OI;
slove();
return ;
}

T3:chocolatebox

题解:请自行推导公式,数学题

总的来说,这套题,两个T3(实现了让人不想看的目标),T2都是图论题,也需要一些分析和转化,总体不错;

但这套题很恶心的地方是,卡常卡的太厉害(你能想象day1T1被卡的全T吗?),day1T2写完了正解后,交上去发现一直T,直到我抄了std的输入之后......

桑心过度;

祝初赛考出好成绩,啦啦啦......

10.19-10.20 test的更多相关文章

  1. [Linux] 树莓派 4B 安装 Ubuntu 19.10 (Eoan Ermine) IOT 版

    硬件:Raspberry Pi 4B系统:Ubuntu 19.10 (Eoan Ermine) for IOT官网:https://ubuntu.com/download/iot/raspberry- ...

  2. Ubuntu 19.10将使用GCC 9作为默认编译器

    作为我们这一周期一直期待的变化,Ubuntu 19.10升级到GCC 9作为GCC 8的默认系统编译器. Ubuntu 19.10(和Ubuntu 20.04 LTS)将使用GCC 9 stable作 ...

  3. 程序员的 Ubuntu 19.10 配置与优化指南

    原文地址:程序员的 Ubuntu 19.10 配置与优化指南 0x00 环境 CPU: Intel Core i9-9900k GPU: GeForce RTX 2070 SUPER RAM: DDR ...

  4. 背水一战 Windows 10 (19) - 绑定: TemplateBinding 绑定, 与 RelativeSource 绑定, 与 StaticResource 绑定

    [源码下载] 背水一战 Windows 10 (19) - 绑定: TemplateBinding 绑定, 与 RelativeSource 绑定, 与 StaticResource 绑定 作者:we ...

  5. Scrum会议10.19

    Scrum会议 组名称:好好学习 项目名称:记账本 参会成员:林莉(Master)胡丽娜 宫丽君 汪东涵 时间:2016.10.19 已完成内容: 1.完成新项目的查找,查找学姐的代码和项目. 2.理 ...

  6. sql 第 10条 到20条

    sql 第 10条 到20条 select * from( select *,ROW_NUMBER () over (order by @@servername) as rownum from tb_ ...

  7. 复杂的字符串数组解析:{"setting":"简单:10:5,一般:5:10,困难:2:20"},使用split多次截取

    "[0,{"id":563,"name":"测试题1","dscr":null,"picId&quo ...

  8. IDC Digital Transition Annual Festival(2018.10.19)

    时间:2018.10.19地点:北京万达文化酒店

  9. 2018.10.19浪在ACM 集训队第一次测试赛

    2018.10.19浪在ACM 集训队第一次测试赛 待参考资料: [1]:https://blog.csdn.net/XLno_name/article/details/78559973?utm_so ...

  10. 20172319 2018.10.19《Java程序设计教程》第7周课堂实践(补写博客)

    20172319 2018.10.19 <Java程序设计教程>第7周课堂实践 课程:<程序设计与数据结构> 班级:1723 学生:唐才铭 学号:20172319 指导老师:王 ...

随机推荐

  1. mybatis trim

    eg: select * from user <trim prefix="WHERE" prefixoverride="AND |OR"> < ...

  2. JAVA中获取不重复的随机数

    我们知道 Random random = new  Random() 中可能会获取到重复的随机数 那么假设要获取1到33之间的六个不重复随机数应该怎么做呢? 首先定义一个数字数组存储1到33 int[ ...

  3. Ext grid单元格编辑时获取获取Ext.grid.column.Column

    item2.width = 80; //item2.flex = 1; item2.align = 'center'; item2.menuDisabled = true; //禁止显示列头部右侧菜单 ...

  4. 在CentOS上安装 MongoDB

    安装是在线安装方式,因此必须先保证能正常上网. 安装mongodb,官方的安装文档,是在线安装方式: https://docs.mongodb.com/manual/tutorial/install- ...

  5. cocos2d-x step by step(2) 鼠标事件,键盘事件,等等事件

    各种小控件加载进去了,那么问题来了,这些东西如何接受事件呢? good job,let us find the answer 首先我们去看文档,官方尼玛有好多文档,而且大,全,详细,感觉还是不错的 h ...

  6. 10.【nuxt起步】-引用mintui

    这时候我们完成了list.vue,但是怎么返回index.vue,这时候需要这个头部返回 1.我们使用现成的minu-ui,eleme的开源移动端 ,参考 https://www.cnblogs.co ...

  7. 【层次查询】Hierarchical Queries之亲兄弟间的排序(ORDER SIBLINGS BY)

    http://blog.itpub.net/519536/viewspace-624176 有关层次查询之前的文章参考如下. [层次查询]Hierarchical Queries之"树的遍历 ...

  8. 微信公众平台SDK for node

    实现了下面特性: 1.开启开发人员模式 2.解析微信请求參数 3.验证消息来源 4.被动回复文字消息 5.被动回复图文消息 6.获取access_token 7.创建自己定义菜单 地址:wechat ...

  9. linux下的环境文件设置说明

    工作环境设置文件 环境设置文件有两种:系统环境设置文件 和 个人环境设置文件   1.系统中的用户工作环境设置文件:   登录环境设置文件:/etc/profile        非登录环境设置文件: ...

  10. 电源滤波电容在PCB中正确的布线方法!

    电源滤波电容在PCB中正确的布线方法! 错误的电源滤波电容布线方法. 1.很多人朋友在设计的时候喜欢加宽这个电源的走,这个是一个很好的方法,但是他们如果一不小心就会忽略电容的布线. 下面的电容布线看起 ...