和FallDream dalao一起从学长那借了个小号打Div2,他切ABE我做CD,我这里就写下CD题解,剩下的戳这里

AC:All Rank:33 小号Rating:1539+217->1756

C.Alyona and Spreadsheet

题目大意:给出一个n*m的数字矩阵a,k次询问,每次给li,ri,求是否有一列的a[li][j],a[li+1][j],...a[ri][j]组成一个不下降序列。(n*m<=100,000,k<=100,000)

思路:O(n*m)扫一遍可以预处理出每个ri最小的li,我菜,写了线段树。

#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
inline int read()
{
int x=;char c;
while((c=getchar())<''||c>'');
for(;c>=''&&c<='';c=getchar())x=(x<<)+(x<<)+c-'';
return x;
}
#define MN 100000
#define N 131072
#define INF 0x7FFFFFFF
vector<int> v[MN+];
vector<pair<int,int> > q[MN+];
int t[N*+],ans[MN+];
void change(int k,int x){for(t[k+=N]=x;k>>=;)t[k]=min(t[k<<],t[(k<<)+]);}
int main()
{
int n,m,k,i,j;
n=read();m=read();
for(i=;i<=m;++i)v[].push_back(INF);
for(i=;i<=n;++i)v[i].push_back();
for(i=;i<=n;++i)for(j=;j<=m;++j)v[i].push_back(read());
for(k=read(),i=;i<k;++i)j=read(),q[read()].push_back(make_pair(j,i));
memset(t,,sizeof(t));
for(i=;i<=n;++i)
{
for(j=;j<=m;++j)if(v[i][j]<v[i-][j])change(j,i);
for(j=;j<q[i].size();++j)ans[q[i][j].second]=(t[]<=q[i][j].first);
}
for(i=;i<k;++i)puts(ans[i]?"Yes":"No");
}

D.

题目大意:给N个字符串,从中删掉最少的字符使得字符串按字典序排序。(字符数量<=500,000)

思路:我写了个分治……solve(l,r,p)表示第l个到第r个前p-1个都一样,从后往前找到第一个s[i][p]>s[i+1][p],把第l个到第i个p以后都截掉,然后按第p个字符分成几块继续分治。其实只要从最后一个往前贪心删掉就可以了。

#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
#define MN 500000
#define INF 0x7FFFFFFF
string s[MN+];
int L[MN+];
int C(int x,int y){return y<=L[x]?s[x][y]:;}
void solve(int l,int r,int p)
{
int i,j,mn=INF;
for(i=r;i>=l;--i)
{
if(C(i,p)>mn)L[i]=p-;
mn=min(mn,C(i,p));
}
for(i=l;i<=r;i=j)
{
for(j=i;j<=r&&C(i,p)==C(j,p);++j);
if(C(i,p))solve(i,j-,p+);
}
}
int main()
{
int n,i,j;
cin>>n;
for(i=;i<=n;++i)
{
cin>>s[i];
L[i]=s[i].size()-;
}
solve(,n,);
for(i=;i<=n;++i,puts(""))for(j=;j<=L[i];++j)putchar(s[i][j]);
}

Codeforces Round #401 (Div. 2)的更多相关文章

  1. Codeforces Round #401 (Div. 2) 离翻身就差2分钟

    Codeforces Round #401 (Div. 2) 很happy,现场榜很happy,完全将昨晚的不悦忘了.终判我校一片惨白,小董同学怒怼D\E,离AK就差一个C了,于是我AC了C题还剩35 ...

  2. Codeforces Round #401 (Div. 2) C Alyona and Spreadsheet —— 打表

    题目链接:http://codeforces.com/contest/777/problem/C C. Alyona and Spreadsheet time limit per test 1 sec ...

  3. Codeforces Round #401 (Div. 2) D Cloud of Hashtags —— 字符串

    题目链接:http://codeforces.com/contest/777/problem/D 题解: 题意:给出n行字符串,对其进行字典序剪辑.我自己的想法是正向剪辑的,即先对第一第二个字符串进行 ...

  4. D Cloud of Hashtags Codeforces Round #401 (Div. 2)

    Cloud of Hashtags [题目链接]Cloud of Hashtags &题意: 给你一个n,之后给出n个串,这些串的总长度不超过5e5,你要删除最少的单词(并且只能是后缀),使得 ...

  5. C Alyona and Spreadsheet Codeforces Round #401(Div. 2)(思维)

    Alyona and Spreadsheet 这就是一道思维的题,谈不上算法什么的,但我当时就是不会,直到别人告诉了我,我才懂了的.唉 为什么总是这么弱呢? [题目链接]Alyona and Spre ...

  6. Codeforces Round #401 (Div. 2) A,B,C,D,E

    A. Shell Game time limit per test 0.5 seconds memory limit per test 256 megabytes input standard inp ...

  7. Codeforces Round #401 (Div. 2) A B C 水 贪心 dp

    A. Shell Game time limit per test 0.5 seconds memory limit per test 256 megabytes input standard inp ...

  8. Codeforces Round #401 (Div. 1) C(set+树状数组)

    题意: 给出一个序列,给出一个k,要求给出一个划分方案,使得连续区间内不同的数不超过k个,问划分的最少区间个数,输出时将k=1~n的答案都输出 比赛的时候想的有点偏,然后写了个nlog^2n的做法,T ...

  9. 【贪心】Codeforces Round #401 (Div. 2) D. Cloud of Hashtags

    从后向前枚举字符串,然后从左向右枚举位. 如果该串的某位比之前的串的该位小,那么将之前的那串截断. 如果该串的某位比之前的串的该位大,那么之前那串可以直接保留全长度. 具体看代码. #include& ...

随机推荐

  1. 学号:201621123032 《Java程序设计》第12周学习总结

    1:本周学习总结 1.1:以你喜欢的方式(思维导图或其他)归纳总结多流与文件相关内容. 2:面向系统综合设计-图书馆管理系统或购物车 2.1: 简述如何使用流与文件改造你的系统.文件中数据的格式如何? ...

  2. 201621123031 《Java程序设计》第14周学习总结

    1. 本周学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结与数据库相关内容. 2. 使用数据库技术改造你的系统 2.1 简述如何使用数据库技术改造你的系统.要建立什么表?截图你的表设计. 答 ...

  3. android 自定义ScrollView实现背景图片伸缩(阻尼效果)

    android 自定义ScrollView实现强调内容背景图片伸缩(仿多米,qq空间背景的刷新) 看到一篇文章,自己更改了一下bug: 原文地址:http://www.aiuxian.com/arti ...

  4. 【微软大法好】VS Tools for AI全攻略(2)

    接着上文,我们来讨论如何使用Azure资源来训练我们的tensorflow项目.Azure云我个人用得很多,主要是因为微软爸爸批了150刀每月的额度,我可以愉快地玩耍. 那么针对Azure,有成套的两 ...

  5. mysql数据库基本操作

    下载地址 http://www.mysql.com/downloads/mysql/ 端口号:3306 用户名:root 密码:自定义 连接到MySQL服务器 >mysql -uroot -pr ...

  6. 初次面对c++

    第一次实验 2-4源码: #include<iostream> using namespace std; int main() { int day; cin>>day; swi ...

  7. SpringBoot入门:Spring Data JPA 和 JPA(理论)

    参考链接: Spring Data JPA - Reference Documentation Spring Data JPA--参考文档 中文版 纯洁的微笑:http://www.ityouknow ...

  8. 阿里云API网关(1)服务网关的产品概述

    网关指南: https://help.aliyun.com/document_detail/29487.html?spm=5176.doc48835.6.550.23Oqbl 网关控制台: https ...

  9. React-redux使用中有关Provider问题

    先上错误: Warning: Failed prop type: Invalid prop `children` of type `array` supplied to `Provider`, exp ...

  10. Oracle复合B*tree索引branch block内是否包含非先导列键值?

    好久不碰数据库底层细节的东西,前几天,一个小家伙跑来找我,非要说复合b*tree index branch block中只包含先导列键值信息,并不包含非先导列键值信息,而且还dump了branch b ...