这套月赛题不是特别难

T1:离散化+单调队列,队列里出现数的种类不超过K+1,找最大的num[a[i]]

T2:一眼可以看出BFS+状压DP,还要SPFA预处理出各个块之间的dis

T3:线段树,没什么难度

 #include<stdio.h>
 #include<string.h>
 #include<algorithm>
 using namespace std;
 ;
 int n,K,a[maxn],b[maxn],m,ans,head,tail,q[maxn],vis[maxn],cnt;
 int main(){
     scanf("%d%d", &n, &K);
     ; i<=n; i++) scanf("%d", &b[i]),a[i]=b[i];
     sort(b+,b++n);
     m=unique(b+,b++n)-b-;
     ; i<=n; i++) a[i]=lower_bound(b+,b++m,a[i])-b;
     //for (int i=1; i<=n; i++) printf("%d\n", a[i]);
     head=tail=cnt=;
     ; i<=n; i++){
         if (!vis[a[i]]) cnt++;
         vis[a[i]]++; q[tail++]=i;
         ){
             vis[a[q[head]]]--; ) cnt--;
             head++;
         }
         ans=max(ans,vis[a[q[tail-]]]);
     }
     printf("%d\n", ans);
     ;
 }
 #include<stdio.h>
 #include<string.h>
 #include<algorithm>
 #include<queue>
 using namespace std;
 ;
 ]={,,,-};
 ]={,-,,};
 struct node{
     int x,y;
     node(int _x, int _y):x(_x),y(_y){}
 };
 <<][],dis[][],id[maxn][maxn],vis[maxn][maxn],cnt,stx[],sty[],N;
 char s[maxn][maxn];

 bool check(int x, int y){
      || y< || x>n || y>m) ; ;
 }

 void bfs(int sx, int sy, int num){
     queue<node> Q;
     Q.push(node(sx,sy)); id[sx][sy]=num;
     vis[sx][sy]=;
     while (!Q.empty()){
         int x=Q.front().x, y=Q.front().y; Q.pop();
         ; k<; k++){
             int tx=x+dx[k], ty=y+dy[k];
             if (check(tx,ty) && !vis[tx][ty] && s[tx][ty]=='X'){
                 vis[tx][ty]=; id[tx][ty]=num;
                 Q.push(node(tx,ty));
             }
         }
     }
 }

 void find_land(){
     cnt=;
     ; i<=n; i++)
         ; j<=m; j++)
             if (s[i][j]=='X' && !vis[i][j]){
                 bfs(i,j,++cnt);
                 stx[cnt]=i; sty[cnt]=j;
             }
 //    for (int i=1; i<=cnt; i++) printf("  %d %d\n", stx[i], sty[i]);
 }

 void spfa(int sx, int sy, int num){
     queue<node> Q;
     int next,cost; memset(d,0x3f,sizeof(d));
     memset(dis[num],0x3f,sizeof(dis[num]));
     Q.push(node(sx,sy)); d[sx][sy]=; vis[sx][sy]=; dis[num][num]=;
     while (!Q.empty()){
         int x=Q.front().x, y=Q.front().y; Q.pop();
         ; k<; k++){
             int tx=x+dx[k], ty=y+dy[k];
             if (!check(tx,ty) || s[tx][ty]=='.') continue;
             cost=(s[tx][ty]=='S');
             if (d[tx][ty]>d[x][y]+cost){
                 d[tx][ty]=d[x][y]+cost;
                 ){
                     vis[tx][ty]=;
                     Q.push(node(tx,ty));
                 }
             }
             if ((s[tx][ty]=='X') && ((next=id[tx][ty])!=num)) dis[num][next]=min(dis[num][next],d[tx][ty]);
         }
         vis[x][y]=;
     }
 }

 void dp(){
     N=(<<cnt);
     memset(f,0x3f,sizeof(f));
     ; i<=cnt; i++) f[(<<(i-))][i]=;
     ; s<N; s++){
         ; i<=cnt; i++) <<(i-)))
             ; j<=cnt; j++) <<(j-))))
                 f[s^(<<(j-))][j]=min(f[s^(<<(j-))][j],f[s][i]+dis[i][j]);
     }
     int ans=0x7fffffff;
     ; i<=cnt; i++) ans=min(ans,f[N-][i]);
     printf("%d\n", ans);
 }

 int main(){
     scanf("%d%d", &n, &m);
     ; i<=n; i++){
         scanf();
     }
     find_land();
     ; i<=cnt; i++)
         spfa(stx[i],sty[i],i);
     dp();
     ;
 }
 #include<stdio.h>
 #include<string.h>
 #include<algorithm>
 using namespace std;
 ;
 struct node{
     int l,r,len,lz,lm,rm,mx;
 }t[maxn*],now;
 int n,m,x,y,ans;
 ];

 void pushup(int x){
     t[x].lm=t[x<<].lm;
     ].lm==t[x<<].len) t[x].lm=t[x<<].len+t[x<<|].lm;
     t[x].rm=t[x<<|].rm;
     |].rm==t[x<<|].len) t[x].rm=t[x<<|].len+t[x<<].rm;
     t[x].mx=max(t[x<<].rm+t[x<<|].lm,max(t[x<<].mx,t[x<<|].mx));
 }

 void pushdown(int x){
     ){  //涂色
         t[x<<].lz=; t[x<<|].lz=;
         t[x<<].lm=t[x<<].rm=t[x<<].mx=;
         t[x<<|].lm=t[x<<|].rm=t[x<<|].mx=;
     }
     ){ //不涂色
         t[x<<].lz=; t[x<<|].lz=;
         t[x<<].lm=t[x<<].rm=t[x<<].mx=t[x<<].len;
         t[x<<|].lm=t[x<<|].rm=t[x<<|].mx=t[x<<|].len;
     }
     t[x].lz=;
 }

 node query(int x, int p){
     int l=t[x].l, r=t[x].r;
     pushdown(x);
     ].mx>=p) ,p);
     ].rm+t[x<<|].lm>=p){
         node ret;
         ret.l=t[x<<].r-t[x<<].rm+;
         ret.r=ret.l+p-;
         return ret;
     }|,p);
 }

 void update(int a, int b, int x, int c){
     int l=t[x].l, r=t[x].r;
     if (l==a && r==b){
         ){
             t[x].lz=;
             t[x].lm=t[x].rm=t[x].mx=;
         }
         ){
             t[x].lz=;
             t[x].lm=t[x].rm=t[x].mx=t[x].len;
         }
         return;
     }
     ;
     pushdown(x);
     ,c);
     |,c);
     ,c),update(mid+,b,x<<|,c);
     pushup(x);
 }

 void build(int l, int r, int x){
     t[x].l=l; t[x].r=r; t[x].len=r-l+;
     if (l==r){
         t[x].lz=; t[x].lm=t[x].rm=t[x].mx=;
         return;
     }
     ;
     build(l,mid,x<<);
     build(mid+,r,x<<|);
     pushup(x);
 }

 int main(){
     scanf("%d%d", &n, &m);
     build(,n,);
     //printf("%d\n", t[1].mx);
     while (m--){
         scanf("%s", opt);
         ]=='A'){
             scanf("%d", &x);
             ].mx<x) ans++;
             else{
                 now=query(,x);
                 //printf(" %d %d\n", now.l, now.r);
                 update(now.l,now.r,,);
             }
         }else{
             scanf("%d%d", &x, &y);
             update(x,y,,);
         }
     }
     printf("%d\n", ans);
     ;
 } 

bzoj3048+3049+3050的更多相关文章

  1. Bzoj索引

    1001 : http://ideone.com/4omPYJ1002 : http://ideone.com/BZr9KF1003 : http://ideone.com/48NJNh1004 : ...

  2. Hsql中In没有1000的限制

    SELECT * FROM user , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ...

  3. 存储过程数据insert into select

    create or replace procedure PRO_K3_CZZH (org_name in varchar2, --财政专户名称 opertype in varchar2, --操作类型 ...

  4. jqu

    1 /*2 * 说明:3 * 本源代码的中文注释乃Auscarlin呕心沥血所作.旨在促进jQuery的传播以及向广大jQuery爱好者提供一个进阶4 *的途径,以让各位更加深入地了解jQuery,学 ...

  5. 7.12归来赛_B

    Prime Judge 时间限制 1000 ms 内存限制 65536 KB 题目描写叙述 众所周知.假设一个正整数仅仅能被1和自身整除,那么该数被称为素数.题目的任务非常easy.就是判定一个数是否 ...

  6. 【8.0.0_r4】AMS分析(十六)(ActivityManagerService.java上)

    代码位于frameworks/base/services/core/java/com/android/server/am/,一共有七十个文件. Java源码位于package com.android. ...

  7. POJ -3050 Hopscotch

    http://poj.org/problem?id=3050 给定一个5×5矩阵,问选6个数的不同排列总数是多少! 二维的搜索,注意要判重,数据量很小,直接用map就好. #include<cs ...

  8. hdu - 3049 - Data Processing(乘法逆元)

    题意:N(N<=40000)个数n1, n2, ..., nN (ni<=N),求(2 ^ n1 + 2 ^ n2 + ... + 2 ^nN) / N % 1000003. 题目链接:h ...

  9. LOJ 3049: 洛谷 P5284: 「十二省联考 2019」字符串问题

    题目传送门:LOJ #3049. 题意简述: 给定一个长度为 \(n\) 的母串 \(S\). 有 \(n_a\) 个 A 类串,都是 \(S\) 的子串,以区间的形式给出. 有 \(n_b\) 个 ...

随机推荐

  1. 6. UIImageView 的使用

    1. UIImageView 的认识 QQ:853740091 UIImageView 继承UIView,通过他的名字我们也可以看出这个是用来显示图片的 2. 使用方法 UIImageView *im ...

  2. Http与Socket小谈

    http与socket是网络编程中最为重要的概念,不管是客户端还是服务端,都是最为重要的部分,以下简述两者的关系和区别(个人见解). Http 定义 基于应用层的超文本传输协议.通常承载于TCP/IP ...

  3. Sublime Text 2 设置tab空格

    打开Sublime Text 2 英文版:选择Preference-defalut 中文版:选择Preference-键绑定-默认 找到"translate_tabs_to_spaces&q ...

  4. 使用Selector改变TextView的字体颜色textColor的方法

    先上Selector文件,名字为singer_fragment_top_text_style.xml, <?xml version="1.0" encoding=" ...

  5. Linux内核--内核数据类型

    转自:http://www.linuxidc.com/Linux/2013-12/93637.htm 将Linux 移植到新的体系结构时,开发者遇到的若干问题都与不正确的数据类型有关.坚持使用严格的数 ...

  6. SOUI与WTL

    如果你想使用SOUI最好有点WTL基础,一点点就行了. SOUI不依赖于WTL,但是SOUI的编码风格基本和WTL一样的:SOUI抄袭了WTL的消息处理形式,SOUI的事件处理也是模仿了WTL的消息映 ...

  7. 各类坐标系相互之间的转换(84互转GC02,GC02互转BD09)

    在遥感行业我们经常会用到各类的坐标系相互之间的转换,常见的度分秒转化为度很简单,直接上代码: //经纬度 ////118度48分54.152秒=118+(48/60)+(54.152/3600)=11 ...

  8. git 的基本使用

    git 的使用步骤: 1. 新建一个文件夹,然后进入终端, 2. cd <文件夹路径>  ——->进入当前目录: 2.psw    ————>查看当前路径 3.git init ...

  9. 在Spring中轻松写日志

    最近觉得写的一点代码(JAVA),还觉得颇为自得,贡献出来供大家参考. 首先,先上代码: @Controller public class Controller1{ @WriteLog(value = ...

  10. Beta工作比例(Transcend)

    Beta工作比例 成员 工作 黄志明 10% 洪志兴 10% 李佳恺 17 % 巫振格 17 % 肖承志 10 % 李严 16 % 牛妍辉 stripes 20%