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. 使用vue-cli搭建element-ui项目

    最近在使用element-ui搭建项目时发现若只纯用webpack来运行element-ui,要配置各种文件,对于新手来说实在太不友好了, 就想到用vue-cli来搭建整个vue项目 1.安装node ...

  2. python3 - 多线程和协程速率测试对比

    多线程和协程都属于IO密集型,我通过以下用例测试多线程和协程的实际速率对比. 实例:通过socket客户端以多线程并发模式请求不同服务器端(这里服务器端分2种写法:第一种服务器通过协程实现,第二种服务 ...

  3. 51 NOD 1407 and and and and !!

    首先与等于零   相当于要求 每一位 在选的数里都有至少一个在该位为 0.直接求这个不太好求,我们考虑容斥: 设F(s) 为 不合法的位的集合至少是s的方案数 ,某一位不合法当且仅当选的数在这一位都是 ...

  4. spring-boot实战【01】:Hello World项目搭建

    原文:http://www.cnblogs.com/yucongblog/p/7355519.html 简介 在您第1次接触和学习Spring框架的时候,是否因为其繁杂的配置而退却了?在你第n次使用S ...

  5. python 列表结构更新的奇妙问题

    使用python + plt 画图遇到了一个奇怪的问题 应该出来的是这样: 结果做出来以后是这样: 为什么画到一起了...... 这个锅python列表背 a=[1,2]b=a  这样  改变b ,a ...

  6. [c#菜鸟]lambda表达式

    what 一.定义 Lambda 表达式是一种可用于创建 委托 或 表达式目录树 类型的 匿名函数 .通过使用 lambda 表达式,可以写入可作为参数传递或作为函数调用值返回的本地函数.(微软) 理 ...

  7. Linux以下基于TCP多线程聊天室(server)

    接上篇博文,本文是server端的实现,主要实现的功能,就是现实client的连接.转发client发送的消息.以及client掉线提示等功能,同一时候能够在这这上面扩展和TCP以及线程相关的功能木块 ...

  8. ubuntu boot空间不足

    在安装 Ubuntu的时候 , 给/boot文件目录分配空间的时候,是100M,/boot可以单独分成一个区,也可以不单独分,在/(根目录)下也会自动为其创建一个boot目录.顺便提一下,Linux分 ...

  9. 解决MySQL出现大量unauthenticated user的问题

    近期OJ及相关的站点打开异常的慢,简直崩溃,一直没找着原因. 进入数据库server.进到mysql里,用show processlist命令查看一下,发现有非常多的unauthenticated u ...

  10. vim 模式切换

    1. 从插入模式退回到normal模式 <esc> <C-c> <C-[>