NOIp 0916 爆零记
题目来自神犇chad
上次爆零是说着玩,这次真的爆零了QAQ
好吧貌似是TYVJ的模拟赛打多了..一直按照TYVJ的格式提交的压缩包..
然后莫名其妙就AK了hhh
来的时候迟到了半小时,昨晚痛苦的补作业补到了1点..,晚上补作业留下的泪就是白天浪时脑子里进的水
所以刚来的时候脑子有点昏,所以T1又是喜闻乐见的不会..
然后按照以往的套路滚去看T2
慢着...这道题好像有些眼熟?这不是我之前放在OJ上的一道题嘛 skip!
去看了看T3,Tarjan+分层图。可以,这很图论,水了一发模板
//chad round T3
//by Cydiater
//2016.9.16
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <queue>
#include <map>
#include <ctime>
#include <cmath>
#include <iostream>
#include <cstdlib>
using namespace std;
#define ll long long
#define up(i,j,n) for(int i=j;i<=n;i++)
#define down(i,j,n) for(int i=j;i>=n;i--)
typedef pair<int,int> pii;
#define FILE "trip"
;
const int oo=0x3f3f3f3f;
inline int read(){
,f=;
;ch=getchar();}
+ch-';ch=getchar();}
return x*f;
}
,LEN=,Link[MAXN],group[MAXN],group_num=,dfn[MAXN],low[MAXN],dfs_clock=,stack[MAXN],top=,Node[MAXN][],cnt=,dis[MAXN],ans=;
priority_queue<pii, vector<pii>, greater<pii> >q;
bool vis[MAXN];
struct edge{
int x,y,next,v;
}e[MAXN],E[MAXN<<];
namespace solution{
inline void insert(int x,int y,int v){e[++len].next=LINK[x];LINK[x]=len;e[len].y=y;e[len].v=v;e[len].x=x;}
inline void Insert(int x,int y,int v){E[++LEN].next=Link[x];Link[x]=LEN;E[LEN].y=y;E[LEN].v=v;E[LEN].x=x;}
void init(){
N=read();M=read();K=read();
up(i,,M){
int x=read(),y=read(),v=read();
insert(x,y,v);
}
}
void tarjan(int node){
vis[node]=;dfn[node]=low[node]=++dfs_clock;
stack[++top]=node;
for(int i=LINK[node];i;i=e[i].next)
if(!dfn[e[i].y]){
tarjan(e[i].y);
low[node]=min(low[node],low[e[i].y]);
}else if(vis[e[i].y]) low[node]=min(low[node],dfn[e[i].y]);
if(dfn[node]==low[node]){
group_num++;
int tmp;
do{
tmp=stack[top--];
vis[tmp]=;
group[tmp]=group_num;
}while(tmp!=node);
}
}
void dijkstra(){
memset(dis,,sizeof(dis));
memset(vis,,sizeof(vis));
dis[Node[group[]][]]=;q.push(make_pair(dis[Node[group[]][]],Node[group[]][]));
while(!q.empty()){
pii tmp=q.top();q.pop();
int dist=tmp.first,node=tmp.second;
if(vis[node])continue;
vis[node]=;
for(int i=Link[node];i;i=E[i].next)
if(dis[E[i].y]>dis[node]+E[i].v){
dis[E[i].y]=dis[node]+E[i].v;
q.push(make_pair(dis[E[i].y],E[i].y));
}
}
}
void slove(){
memset(vis,,sizeof(vis));
memset(dfn,,sizeof(dfn));
memset(low,,sizeof(low));
up(i,,N)if(!dfn[i])tarjan(i);
up(i,,N)up(k,,K)Node[i][k]=++cnt;
up(i,,len){
int x=e[i].x,y=e[i].y,v=e[i].v;
if(group[x]==group[y])continue;
up(k,,K) Insert(Node[group[x]][k],Node[group[y]][k],v);
up(k,,K-) Insert(Node[group[x]][k],Node[group[y]][k+],);
}
dijkstra();
}
void output(){
up(k,,K)ans=min(ans,dis[Node[group[N]][k]]);
)ans=-;
cout<<ans<<endl;
}
}
int main(){
//freopen("input.in","r",stdin);
freopen(FILE".in","r",stdin);
freopen(FILE".out","w",stdout);
using namespace solution;
init();
slove();
output();
;
}
这些模板敲过好几遍了,不拍了。去看T1!
$ans \leq 50$
好呀,搞个二维前缀和枚举
//chad round T1
//by Cydiater
//2016.9.16
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#include <queue>
#include <map>
#include <iomanip>
#include <ctime>
#include <cmath>
using namespace std;
#define ll long long
#define up(i,j,n) for(int i=j;i<=n;i++)
#define down(i,j,n) for(int i=j;i>=n;i--)
#define FILE "papercut"
;
const int oo=0x3f3f3f3f;
inline int read(){
,f=;
;ch=getchar();}
+ch-';ch=getchar();}
return x*f;
}
int N,M,K,cnt[MAXN][MAXN];
namespace solution{
void init(){
N=read();M=read();K=read();
memset(cnt,,sizeof(cnt));
up(i,,K){
int x=read(),y=read();
cnt[x][y]=;
}
up(i,,N)up(j,,M)cnt[i][j]=cnt[i-][j]+cnt[i][j-]-cnt[i-][j-]+cnt[i][j];
}
void slove(){
down(ans,min(min(N,M),),){
up(i,ans,N)up(j,ans,M){
int tmp1=cnt[i][j],tmp2=cnt[i][j-ans]+cnt[i-ans][j]-cnt[i-ans][j-ans];
){
printf("%d\n",ans);
return;
}
}
}
puts(");
}
}
int main(){
//freopen("input.in","r",stdin);
freopen(FILE".in","r",stdin);
freopen(FILE".out","w",stdout);
using namespace solution;
init();
slove();
;
}
然后水了水T2的模板
//chad round T2
//by Cydiater
//2016.9.16
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <queue>
#include <map>
#include <iomanip>
#include <cstdlib>
#include <ctime>
#include <cmath>
using namespace std;
#define ll long long
#define up(i,j,n) for(int i=j;i<=n;i++)
#define down(i,j,n) for(int i=j;i>=n;i--)
#define FILE "string"
;
const int oo=0x3f3f3f3f;
inline int read(){
,f=;
;ch=getchar();}
+ch-';ch=getchar();}
return x*f;
}
char s[MAXN];
,ans=;
namespace solution{
inline bool equ(int x,int y,int l){return rank[x]==rank[y]&&rank[x+l]==rank[y+l];}
void init(){
scanf();
N=strlen(s+);
}
void suffix_sort(){
up(i,,N){rank[i]=s[i];sa[i]=i;}
,i,sig=,pos=;pos<N;sig=pos){
,i=N-l+;i<=N;i++)p[++pos]=i;
;i<=N;i++)if(sa[i]>l)p[++pos]=sa[i]-l;
;i<=sig;i++)cnt[i]=;
;i<=N;i++)cnt[rank[i]]++;
;i<=sig;i++)cnt[i]+=cnt[i-];
for(i=N;i;i--)sa[cnt[rank[p[i]]]--]=p[i];
,i=;i<=N;i++)tmp[sa[i]]=equ(sa[i],sa[i-],l)?pos:++pos;
;i<=N;i++)rank[i]=tmp[i];
l=l==?:l<<;
}
}
void get_height(){
,j=,k;i<=N;i++){
])){j=;continue;}
if(j)j--;
while(s[i+j]==s[k+j])j++;
height[rank[i]]=j;
}
}
void slove(){
suffix_sort();
get_height();
up(i,,N)ans+=N-sa[i]+-height[i];
}
void output(){
cout<<ans<<endl;
}
}
int main(){
//freopen("input.in","r",stdin);
freopen(FILE".in","r",stdin);
freopen(FILE".out","w",stdout);
using namespace solution;
init();
slove();
output();
;
}
小结
除了T2出后缀数组比较坑,其他的题都很不错。其实NOIp通用的知识点就那么几个,关键还是看考试的状态。连着这几场考试都没有数论,很有可能是一个flag..
陷入LCT的坑无法自拔感觉各种基础算法都忘光了
NOIp 0916 爆零记的更多相关文章
- NOIp 0910 爆零记
这套题是神犇chty出的. 刚拿到题的时候有点懵逼,因为按照一般的套路第一题都是一眼题,但是看到第一题后想了很多个算法和数据结构好像都不能很好的解决.然后就随手敲了个暴力去看T2. 嗯...文件名是b ...
- 「游记」NOIP 2021 爆零记
推荐访问本人自建博客 \(\text{cjwen.top}\) 欧拉欧拉欧拉欧拉欧拉欧拉欧拉欧拉,第一次参加 \(NOIP\),欧拉欧拉欧拉欧拉欧拉欧拉欧拉欧拉. 第一题比较简单,用类似于筛质数的做法 ...
- Codeforces Round #423 (Div. 2, rated, based on VK Cup Finals)爆零记
昨晚一个瓜皮说今晚有cf,听说是晚间场,我瞅了一眼,娃,VK Cup,上分的好机会,看着比赛时间就有点心酸了,0:35,当时一直在纠结要不要打的问题,当时想着应该不难吧,要不打一下吧,要不还是看看题先 ...
- HNOI2019 爆零记
HNOI2019爆零记 day \(-inf\) ~ day \(0\) 开学一周之后才停的课,停课之后就开始每天被包菜.我三月份几乎没有更博,就是因为每天都被虐的自闭了. day \(0\) 本来是 ...
- PKUWC 2019&WC 2019爆零记
PKUWC 2019&WC 2019爆零记 毕竟过了很久了,杂七杂八的东西就不写了,并且除成绩之外的内容不保证其正确性. Day1 T1:看到这道题很舒服啊,枚举top序算合法图的数量,状压D ...
- 雅礼集训1-9day爆零记
雅礼集训1-9day爆零记 先膜一下虐爆我的JEFF巨佬 Day0 我也不知道我要去干嘛,就不想搞文化科 (文化太辣鸡了.jpg) 听李总说可以去看(羡慕)各路大佬谈笑风声,我就报一个名吧,没想到还真 ...
- CTS&&APIO2019爆零记
如果你只好奇测试相关请跳至day 2 day 3 day 6 scoi 2019 之后 由于实力问题,省选的时候排名在三十多,显然是没有进队.不过可能是受过的打击比较多,所以还没有特别颓废,甚至连 ...
- [日常] NOIWC 2018爆零记
开个坑慢慢更(逃 (然而没准会坑掉?) day 0 大概 $8:30$ 就滚去雅礼了qwq 过去的时候发现并没有人...进报到处楼门的时候还被强行拍照围观了一波OwO 然后就领了HZ所有人的提包和狗牌 ...
- HNOI2019爆零记
HNOI2019真-爆零祭 我怎么这么菜QAQ day-37 从学科溜过来搞OI. 班主任一直在谈论我退役的事情,这就是NOIP挂分的后果...说我没考好就找理由,人家xxxxxxx可不是xxxxxx ...
随机推荐
- Linux 配置只安装 64 位软件包
Centos.RHEL等系统,yum 安装的时候有时候会安装32的,然而我们只需要安装64位的软件! 解决方法: yum只安装 64 位的包,只需在 /etc/yum.conf 中加入 "e ...
- PotPlayer 1.6.52965 美化版|视频播放器
Potplayer播放器,基本上可以解析大部分的视频格式.作为单机版的视频播放器很不错的选择! Potplayer,只为播放而生! exp: 点击下载
- my-Life项目开发流程
一:新建java web项目 (懂得使用gradle哦!) 1.http://www.cnblogs.com/xylle/p/5234380.html 2.新建项目后,然后新建module, 如果甲 ...
- C#反射设置属性值和获取属性值
/// /// 获取类中的属性值 /// /// /// /// public string GetModelValue(string FieldName, object obj) { try { T ...
- Swift开发小技巧--TabBar中间按钮的添加方案
TabBar中间按钮的添加方案 之前做百思项目的时候,也有一个中间按钮,当时是重写的TabBar,这里介绍一个新的方法 给TabbarVC多添加添加一个控制器,这个控制器的作用仅仅是用来占位的,多了这 ...
- hdu2888 二维RMQ
Check Corners Time Limit: 2000/10000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) T ...
- JSP 中的 tag 文件
在jsp文件中,可以引用 tag 和tld 文件,本文主要针对 tag 对于tag 文件 1)将此类文件放在 WEB-INF 下,比如 /WEB-INF/tags,tags 是目录,其下可以有多个.t ...
- js-回车事件控制
1.文本框回车时间 < script type = "text/javascript" language = "javascript" > fun ...
- 一起学HTML基础-JavaScritp简介与语法
简介: 1.什么是JavaScript? 它是个脚本语言,作用是使 HTML 页面具有更强的动态和交互性,它需要有宿主文件,它的宿主文件就是html文件. JavaScript 是 Web 的编程语 ...
- TCP连接——爱的传声筒
TCP连接——爱的传声筒 TCP通信最重要的特征是:有序(ordering)和可靠(reliable).有序是通过将文本流分段并编号实现的.可靠是通过ACK回复和重复发送(retransmission ...