NOIp2018集训test-10-24(am&pm)
李巨连续AK三场了,我跟南瓜打赌李巨连续AK七场,南瓜赌李巨连续AK五场。
DAY1
T1 qu
按题意拿stack,queue和priority_que模拟即可。特判没有元素却要取出的情况。
T2 ming
贪心发现ddl越小的任务越早完成越好,排序更新答案即可。
T3 zi
可能是昨天看了虚树我脑子不太好用,思维僵化的厉害,打算用虚树搞这道题,然后写了180+,连样例都懒得测知道根本过不了交了个暴力,结果暴力还有70。50min270pt+2h10min0pt。
实际上并不想需要虚树啊,我老想着怎么递推我tm就不能递归吗,递归然后记忆化只有那么好写了。
//Achen
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);i++)
#define Rep(i,a,b) for(int i=(a);i>=(b);i--)
#define Formylove return 0
const int N=,p=1e9+;
typedef long long LL;
typedef double db;
using namespace std;
int m;
LL T[N],sz[N],a[N],b[N],c[N],d[N],l[N]; template<typename T> void read(T &x) {
char ch=getchar(); x=; T f=;
while(ch!='-'&&(ch<''||ch>'')) ch=getchar();
if(ch=='-') f=-,ch=getchar();
for(;ch>=''&&ch<='';ch=getchar()) x=x*+ch-''; x*=f;
} #define pr pair<int,LL>
#define Pr pair<pr,LL>
#define MP make_pair
#define se second
#define fi first map<Pr,LL>D;
LL get_D(int i,LL x,LL y) {
if(x==y) return 0LL;
LL rs=;
if(x>y) swap(x,y);
if(D[MP(MP(i,x),y)]) return D[MP(MP(i,x),y)];
if(x<=sz[a[i]]&&y<=sz[a[i]]) rs=get_D(a[i],x,y);
else if(x>sz[a[i]]&&y>sz[a[i]]) rs=get_D(b[i],x-sz[a[i]],y-sz[a[i]]);
else rs=(get_D(a[i],x,c[i])+get_D(b[i],y-sz[a[i]],d[i])+l[i])%p;
D[MP(MP(i,x),y)]=rs; return rs;
} map<pr,LL>A;
LL get_A(int i,LL x) {
if(sz[i]==) return 0LL;
LL rs=;
if(A[MP(i,x)]) return A[MP(i,x)];
if(x<=sz[a[i]]) rs=(get_A(a[i],x)+get_A(b[i],d[i])+sz[b[i]]*(l[i]+get_D(a[i],c[i],x))%p)%p;
else rs=(get_A(b[i],x-sz[a[i]])+get_A(a[i],c[i])+sz[a[i]]*(l[i]+get_D(b[i],d[i],x-sz[a[i]]))%p)%p;
A[MP(i,x)]=rs; return rs;
} #define ANS
int main() {
#ifdef ANS
freopen("zi.in","r",stdin);
freopen("zi.out","w",stdout);
#endif
read(m);
sz[]=;
For(i,,m) {
read(a[i]); read(b[i]);
read(c[i]); read(d[i]);
c[i]+=; d[i]+=; read(l[i]);
sz[i]=sz[a[i]]+sz[b[i]];
T[i]=(T[a[i]]+T[b[i]]+sz[a[i]]*sz[b[i]]%p*l[i]%p+get_A(a[i],c[i])*sz[b[i]]%p+get_A(b[i],d[i])*sz[a[i]]%p)%p;
}
For(i,,m) printf("%lld\n",T[i]);
Formylove;
}
DAY2
T1 hao
这题数据出锅了吧,说好的一开始没有连着的实际上有而且不能被消去,这样实际上的消的效果就有多种可能了题意描述并不清楚。
一个坑点是读入字符串不能用scanf因为会有空串。
//Achen
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);i++)
#define Rep(i,a,b) for(int i=(a);i>=(b);i--)
#define Formylove return 0
const int N=4e3+;
typedef long long LL;
typedef double db;
using namespace std;
int n,head,pr[N],nxt[N],tot;
char a[N],s[N],o[]; template<typename T> void read(T &x) {
char ch=getchar(); x=; T f=;
while(ch!='-'&&(ch<''||ch>'')) ch=getchar();
if(ch=='-') f=-,ch=getchar();
for(;ch>=''&&ch<='';ch=getchar()) x=x*+ch-''; x*=f;
} void del(int x) {
int cnt=;
char bs=s[x];
if(pr[x]&&s[pr[x]]==bs) {
cnt++;
if(pr[pr[x]]&&s[pr[pr[x]]]==bs) cnt++;
}
if(nxt[x]&&s[nxt[x]]==bs) {
cnt++;
if(nxt[nxt[x]]&&s[nxt[nxt[x]]]==bs) cnt++;
}
if(cnt<) return ;
while(x&&s[x]==bs) {
if(x==head) {
pr[nxt[x]]=;
head=nxt[x];
x=nxt[x];
}
else {
if(nxt[x]) pr[nxt[x]]=pr[x];
nxt[pr[x]]=nxt[x];
if(s[pr[x]]==bs) x=pr[x];
else x=nxt[x];
}
}
if(x) del(x);
} void insert(int pos,char o,int f) {
int x=head,y=++tot;
s[y]=o;
if(!pos) {
nxt[y]=head;
if(head) pr[head]=y;
head=y;
}
else {
For(i,,pos-) x=nxt[x];
if(nxt[x]) {
pr[nxt[x]]=y;
nxt[y]=nxt[x];
}
nxt[x]=y; pr[y]=x;
}
if(f) del(y);
} void print(int x) {
if(!x) { puts(""); return; }
putchar(s[x]);
print(nxt[x]);
} int m=;
void scan() {
char ch=getchar();
for(;;) {
if(ch=='\n'||ch=='\r') break;
a[m++]=ch;
ch=getchar();
}
} #define ANS
int main() {
#ifdef ANS
freopen("hao.in","r",stdin);
freopen("hao.out","w",stdout);
#endif
scan();
For(i,,m-) insert(i,a[i],);
read(n);
For(cs,,n) {
int pos;
read(pos);
scanf("%s",o);
insert(pos,o[],);
if(!head) puts("-");
else print(head);
}
Formylove;
}
T2 kun
维护后缀最大值用栈贪心即可。好像学过栈的人都会吧。
T3 nan
考过的原题啊。发现答案是i*f[i]的前缀和,按f[i]分块地计算一下就好了。跟之前那题唯一的差别是多个询问所以要离线一起做。
//Achen
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);i++)
#define Rep(i,a,b) for(int i=(a);i>=(b);i--)
#define Formylove return 0
const int N=1e6,p=1e9+;
typedef long long LL;
typedef double db;
using namespace std;
int f[N+],T,n;
LL ans=; template<typename T> void read(T &x) {
char ch=getchar(); x=; T f=;
while(ch!='-'&&(ch<''||ch>'')) ch=getchar();
if(ch=='-') f=-,ch=getchar();
for(;ch>=''&&ch<='';ch=getchar()) x=x*+ch-''; x*=f;
} LL dc(LL a,LL b) {
if((a+b)%) return (b-a+)/%p*((a+b)%p)%p;
else return (a+b)/%p*((b-a+)%p)%p;
} struct qs {
int n,id;
friend bool operator <(const qs&A,const qs&B) {
return A.n<B.n;
}
}q[N];
LL rs[N]; #define ANS
int main() {
#ifdef ANS
freopen("nan.in","r",stdin);
freopen("nan.out","w",stdout);
#endif
f[]=; f[]=; f[]=;
int now=;
for(int i=;;i++) {
For(j,,f[i]) {
f[now+j]=i;
if(now+j==N) break;
}
now+=f[i];
if(now>=N) {
now=N; break;
}
}
read(T);
For(i,,T) {
read(q[i].n);
q[i].id=i;
}
sort(q+,q+T+);
int nq=; now=;
ans=;
for(int i=;;i++) {
while(nq<=T&&now+f[i]>=q[nq].n) {
rs[q[nq].id]=(ans+dc(now+,q[nq].n)*i%p)%p;
nq++;
}
if(nq>T) break;
ans=(ans+dc(now+,now+f[i])*i%p)%p;
now+=f[i];
}
For(i,,T) printf("%lld\n",rs[i]);
//cerr<<clock()<<endl;
Formylove;
}
NOIp2018集训test-10-24(am&pm)的更多相关文章
- 背水一战 Windows 10 (24) - MVVM: 通过 Binding 或 x:Bind 结合 Command 实现,通过非 ButtonBase 触发命令
[源码下载] 背水一战 Windows 10 (24) - MVVM: 通过 Binding 或 x:Bind 结合 Command 实现,通过非 ButtonBase 触发命令 作者:webabcd ...
- python中使用Opencv进行车牌号检测——2018.10.24
初学Python.Opencv,想用它做个实例解决车牌号检测. 车牌号检测需要分为四个部分:1.车辆图像获取.2.车牌定位.3.车牌字符分割和4.车牌字符识别 在百度查到了车牌识别部分车牌定位和车牌字 ...
- 10.24 正睿停课训练 Day8 AM
目录 2018.10.24 正睿停课训练 Day8 AM A 棒棒糖(组合) B 彩虹糖(思路 博弈) C 泡泡糖(DP) 考试代码 A B C 2018.10.24 正睿停课训练 Day8 AM 期 ...
- table-cell http://www.cnblogs.com/StormSpirit/archive/2012/10/24/2736453.html
http://www.cnblogs.com/StormSpirit/archive/2012/10/24/2736453.html
- 使用mybatis提供的各种标签方法实现动态拼接Sql。使用foreach标签实现遍历查询。比如实现select * from user where id in(1,10,24)这条sql查询语句。
向sql传递数组或List,mybatis使用foreach解析,如下: 需求: 传入多个id查询用户信息,用下边的sql实现: select * from user where id in(1,10 ...
- [NOIP2018模拟赛10.16]手残报告
[NOIP2018模拟赛10.16]手残报告 闲扯 炉石乱斗模式美滋滋啊,又颓到好晚... 上来T2先敲了树剖,看T1发现是个思博DP,然后没过大样例,写个暴力发现还是没过大样例!?才发现理解错题意了 ...
- Java习题10.24
Java习题10.24 1. 1,3.connect()与accept():这两个系统调用用于完成一个完整相关的建立,其中connect()用于建立连接.accept()用于使服务器等待来自某客户进程 ...
- NOIP2018赛前停课集训记(10.24~11.08)
前言 为了不久之后的\(NOIP2018\),我们的停课从今天(\(Oct\ 24th\))起正式开始了. 本来说要下周开始的,没想到竟提早了几天,真是一个惊喜.毕竟明天有语文考试.后天有科学考试,逃 ...
- NOIp2018集训test-9-21(am/pm)
Am DAY1 抄代码 送分题 //Achen #include<bits/stdc++.h> #define For(i,a,b) for(int i=(a);i<=(b);i++ ...
- 2018.10.24 NOIP2018模拟赛 解题报告
得分: \(100+0+100=200\)(\(T2\)悲惨爆\(0\)) \(P.S.\)由于原题是图片,所以我没有上传题目描述,只有数据. \(T1\):query(点此看题面) 熟悉主席树的人都 ...
随机推荐
- Funq之Lambda表达式入门
今天接受了一个Tranning关于.net3.5 framework中的new feature. 其中最不明白的还是Lambda表达式.回来后又仔细的思考了一番,总算有点体会在这里写一下.既然是入门, ...
- 安装MySQL的详细步骤
安装步骤如下: 1.打开网址:http://www.mysql.com/ ↓ 2.选择“Download”->“Windows”(此安装步骤只是在Window10 中进行,如有需要,其他系统可参 ...
- awk的内置函数
常见awk内置数值函数
- /usr/lib/update-notifier/updates-available
/usrb/update-notifier/update-motd-updates-available: 49: /usrb/update-notifier/update-motd-updates- ...
- P3437 [POI2006]TET-Tetris 3D
题目 P3437 [POI2006]TET-Tetris 3D 做法 一眼就是二维线段树,仔细想想,赋值操作怎么办??\(lazy\)标记放在一维,下一次又来放个标记二维就冲突了 正解:永久化标记 怎 ...
- 【简单dp】poj 1458 最长公共子序列【O(n^2)】【模板】
最长公共子序列可以用在下面的问题时:给你一个字符串,请问最少还需要添加多少个字符就可以让它编程一个回文串? 解法:ans=strlen(原串)-LCS(原串,反串); Sample Input abc ...
- linux shell执行SQL脚本
#!/bin/sh user="user" pass="pass" sqlplus -S $user/$pass select 1 from dual; exi ...
- SQL中的5种常用的聚集函数
首先你要知道 where->group by->having->order by/limit ,这个就是写sql语句时的顺序 常用的5个聚集函数: Max ...
- shell脚本:批量修改文件名
参考链接1:shell脚本:批量修改文件名(删除文件名中字符) 参考链接2:linux shell 字符串操作详解 (长度,读取,替换,截取,连接,对比,删除,位置 ) 参考链接3:每天一个linux ...
- ios 发布相关材料记录
1 app icon Spotlight iOS 5,6 base: 29pt, 需要 @1x, @2x, @3x,得出:29 x 29, 58 x 58, 87 x 87 iOS 7,8 base: ...