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. Java ArrayList 详解

    只记录目前为止关注的.JDK1.8 一.基础属性 1.1 内部参数 //空存储实例.直接new ArrayList()便是以该空数组作为实例 private static final Object[] ...

  2. 用Java做一个跳一跳辅助

    Java跳一跳辅助 首先..让大家看下效果: 由于是闲着没事写的.也懒得看OpenCV的API了. 要用到的工具如下: adb+jdk 把adb添加到环境变量里就行.很简单. 全部代码如下.就这么多. ...

  3. Java RandomAccessFile类

    RandomAccessFile类是Java中操作文件内容功能最强大的类,既可以读,也可以写. RandomAccessFile支持随机访问,可以直接访问文件的任意位置,在文件的任意位置读写数据.如果 ...

  4. PyTorch学习笔记之CBOW模型实践

    import torch from torch import nn, optim from torch.autograd import Variable import torch.nn.functio ...

  5. android_浅析canvas的save()和restore()方法

    <span style="font-size:18px;"> </span> <span style="font-size:18px;&qu ...

  6. requests(爬虫常用)库的使用

    Requests库的使用 基于urllib改写的库 示例: import requests response=requests.get('http://www.baidu.com')#get请求 pr ...

  7. 用ELK 实时处理搜索日志

    转载请标明原处:http://blog.csdn.net/hu948162999/article/details/50563110 本来这块业务 是放到SolrCloud上去的 , 然后 採用solr ...

  8. WMS8_条码界面操作简要说明(包装作业)

    说明:条码界面的主要用途是包装作业 这个客户端,完全是JS实现的     可以从 All operation看板视图 Picking的表单视图                 All operatio ...

  9. matplotlib简易新手教程及动画

    做数据分析,首先是要熟悉和理解数据.所以掌握一个趁手的可视化工具是很重要的,否则对数据连个主要的感性认识都没有,怎样进行下一步的design 点击打开链接 还有一个非常棒的资料  Matplotlib ...

  10. 深入struts2.0(七)--ActionInvocation接口以及3DefaultActionInvocation类

    1.1.1       ActionInvocation类 ActionInvocation定义为一个接口.主要作用是表现action的运行状态.它拥有拦截器和action的实例.通过重复的运行inv ...