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. CCCC L2-024 部落【并查集】

    https://www.patest.cn/contests/gplt/L2-024 首先在一行中输出这个社区的总人数.以及互不相交的部落的个数.随后对每一次查询,如果他们属于同一个部落,则在一行中输 ...

  2. 洛谷—— P2183 巧克力

    https://www.luogu.org/problemnew/show/P2183 题目描述 佳佳邀请了M个同学到家里玩.为了招待客人,她需要将巧克力分给她的好朋友们.她有N(1<=N< ...

  3. 2017 [六省联考] T6 寿司餐厅

    4873: [Shoi2017]寿司餐厅 Time Limit: 20 Sec  Memory Limit: 512 MBSubmit: 450  Solved: 316[Submit][Status ...

  4. springboot快速集成swagger

    今天技术总监说:小明,我们本次3.0改造,使用swagger2.0作为前后端分离的接口规范,它可以一键生成前后端的API,一劳永逸--小明:??? Spring Boot 框架是目前非常流行的微服务框 ...

  5. PHP微信公众平台OAuth2.0网页授权,获取用户信息代码类封装demo(二)

    一.这个文件微信授权使用的是OAuth2.0授权的方式.主要有以下简略步骤: 第一步:判断有没有code,有code去第三步,没有code去第二步 第二步:用户同意授权,获取code 第三步:通过co ...

  6. GitBook一个专注于帮助文档的工具

    官网:https://www.gitbook.com GitHub组织:https://github.com/gitbookio GitBook一个专注于帮助文档的工具,比如: 1.简单的左侧列表右侧 ...

  7. 使用和不使用navigationbar分别处理显示和返回页面

    不使用navigationbar的情况下 AnnounceViewController *pushView = [[AnnounceViewController alloc]init];pushVie ...

  8. dubbo开发者指南

    开发者指南 参与 流程 任务 版本管理 源码构建 框架设计 整体设计 模块分包 依赖关系 调用链 暴露服务时序 引用服务时序 领域模型 基本原则 扩展点加载 扩展点配置 扩展点自动包装 扩展点自动装配 ...

  9. 学会用core dump调试程序错误

    最来在项目中遇到大型程序出现SIGSEGV ,一直不知道用core dump工具来调试程序,花了近一周的时间,才定位问题,老大很生气,后果很严重,呵呵,事后仔细学习了这块的知识,了解一点core du ...

  10. python的私有化

    1.双下划线(__) 由双下划线開始的属性在执行时被混淆,所以直接訪问是不同意的.实际上以双下划线開始的属性 会在解释时在前面加上下划线和类名.如self.__num会被解析为self._classN ...