ARC071

C - 怪文書 / Dubious Document

题目大意:给n个字符串,每个字符串可以通过扔掉一些字母将剩下的字母重排得到新的字符串,求n个字符串都能拼出的字符串且长度最大,若有多个输出字典序最小

直接对每个字母取个min即可

#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 10005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
res = 0;T f = 1;char c = getchar();
while(c < '0' || c > '9') {
if(c == '-') f = -1;
c = getchar();
}
while(c >= '0' && c <= '9') {
res = res * 10 +c - '0';
c = getchar();
}
res *= f;
}
template<class T>
void out(T x) {
if(x < 0) {x = -x;putchar('-');}
if(x >= 10) {
out(x / 10);
}
putchar('0' + x % 10);
}
int N;
char s[55];
int t[30],a[30];
void Solve() {
read(N);
for(int i = 0 ; i < 26 ; ++i) a[i] = 50;
for(int i = 1 ; i <= N ; ++i) {
scanf("%s",s + 1);
int l = strlen(s + 1);
memset(t,0,sizeof(t));
for(int j = 1 ; j <= l ; ++j) t[s[j] - 'a']++;
for(int j = 0 ; j < 26 ; ++j) a[j] = min(a[j],t[j]);
}
for(int i = 0 ; i < 26 ; ++i) {
for(int j = 1 ; j <= a[i] ; ++j) {
putchar('a' + i);
}
}
enter;
}
int main() {
#ifdef ivorysi
freopen("f1.in","r",stdin);
#endif
Solve();
}

D - 井井井 / ###

大意:给n条和x轴平行的线,m条和y轴平行的线,求所有矩形的面积和

就是二维的任意连续子段和相乘即可

#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 10005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
res = 0;T f = 1;char c = getchar();
while(c < '0' || c > '9') {
if(c == '-') f = -1;
c = getchar();
}
while(c >= '0' && c <= '9') {
res = res * 10 +c - '0';
c = getchar();
}
res *= f;
}
template<class T>
void out(T x) {
if(x < 0) {x = -x;putchar('-');}
if(x >= 10) {
out(x / 10);
}
putchar('0' + x % 10);
}
const int MOD = 1000000007;
int N,M,s[2],l[2];
int inc(int a,int b) {
return a + b >= MOD ? a + b - MOD : a + b;
}
int mul(int a,int b) {
return 1LL * a * b % MOD;
}
void update(int &x,int y) {
x = inc(x,y);
}
void Solve() {
read(N);read(M);
int x;
for(int i = 1 ; i <= N ; ++i) {
read(x);
x = (x + MOD) % MOD;
update(l[0],inc(mul(i - 1,x),MOD - s[0]));
update(s[0],x);
}
int y;
for(int i = 1 ; i <= M ; ++i) {
read(y);
y = (y + MOD) % MOD;
update(l[1],inc(mul(i - 1,y),MOD - s[1]));
update(s[1],y);
}
out(mul(l[0],l[1]));
}
int main() {
#ifdef ivorysi
freopen("f1.in","r",stdin);
#endif
Solve();
}

E - TrBBnsformBBtion

大意:一个只包含AB的串,A可以变成BB,B可以变成AA,三个连续相同字母可以删除,问S的一个子串能否变成T的一个子串

把A标值成1,把B标值成2,可以发现一个字符串在取模3意义下和不改变

然后可以发现21可以变成12

用数学归纳法可以证明两个字符串和相等一定可以互相转化,就是把S通过操作和T调成等长度,如果第K + 1个数相等,那么S可以转化成T

其余情况不妨是S的K + 1是1,T的K + 1是2,如果S中含有2可以用21和12的交换把2换过去,否则S就全是1,T就全是2,此时两者长度必然是3的倍数,那么把S所有的1变成2,删掉3的整数倍个2可得到T

这道题的题目名称有点皮

#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
res = 0;T f = 1;char c = getchar();
while(c < '0' || c > '9') {
if(c == '-') f = -1;
c = getchar();
}
while(c >= '0' && c <= '9') {
res = res * 10 +c - '0';
c = getchar();
}
res *= f;
}
template<class T>
void out(T x) {
if(x < 0) {x = -x;putchar('-');}
if(x >= 10) {
out(x / 10);
}
putchar('0' + x % 10);
}
char s[2][MAXN];
int Q;
int sum[2][MAXN];
void Solve() {
scanf("%s%s",s[0] + 1,s[1] + 1);
int l = strlen(s[0] + 1);
for(int i = 1 ; i <= l ; ++i) {
sum[0][i] = sum[0][i - 1];
if(s[0][i] == 'A') sum[0][i] += 1;
else sum[0][i] += 2;
}
l = strlen(s[1] + 1);
for(int i = 1 ; i <= l ; ++i) {
sum[1][i] = sum[1][i - 1];
if(s[1][i] == 'A') sum[1][i] += 1;
else sum[1][i] += 2;
}
read(Q);
int a,b,c,d;
for(int i = 1 ; i <= Q ; ++i) {
read(a);read(b);read(c);read(d);
if((sum[0][b] - sum[0][a - 1]) % 3 == (sum[1][d] - sum[1][c - 1]) % 3) {puts("YES");}
else puts("NO");
}
}
int main() {
#ifdef ivorysi
freopen("f1.in","r",stdin);
#endif
Solve();
}

F - Infinite Sequence

就是如果一个大于等于2的数,连了一个大于等于2的数,那么之后的所有都会被固定

那么我们就算前i个没有出现这种情况的方案数

我们可以在i个后面接上固定下来的情况,也可以第i个直接到终点,也可以是某种X111111....的1需要延续到N之后

#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 1000005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
res = 0;T f = 1;char c = getchar();
while(c < '0' || c > '9') {
if(c == '-') f = -1;
c = getchar();
}
while(c >= '0' && c <= '9') {
res = res * 10 +c - '0';
c = getchar();
}
res *= f;
}
template<class T>
void out(T x) {
if(x < 0) {x = -x;putchar('-');}
if(x >= 10) {
out(x / 10);
}
putchar('0' + x % 10);
}
const int MOD = 1000000007;
int inc(int a,int b) {
return a + b >= MOD ? a + b - MOD : a + b;
}
int mul(int a,int b) {
return 1LL * a * b % MOD;
}
void update(int &x,int y) {
x = inc(x,y);
}
int N;
int sum[MAXN],dp[MAXN];
void Solve() {
read(N);
dp[0] = 1;
sum[0] = 1;
int ans = 0;
for(int i = 1 ; i <= N ; ++i) {
update(dp[i],dp[i - 1]);
if(i >= 3) update(dp[i],sum[i - 3]);
sum[i] = inc(sum[i - 1],dp[i]);
}
for(int i = 0 ; i <= N ; ++i) {
if(i == N - 1) {
update(ans,mul(dp[i],N - 1));
}
else if(i == N) {
update(ans,dp[i]);
}
else {
update(ans,mul(dp[i],mul(N - 1,N - 1)));
}
if(i < N - 1) {
int t = N - i - 1;
update(ans,mul(dp[i],N - t));
}
}
out(ans);enter;
}
int main() {
#ifdef ivorysi
freopen("f1.in","r",stdin);
#endif
Solve();
}

板刷了三页AtCoder……

加油。。。。还有一页半……?

【AtCoder】ARC071的更多相关文章

  1. 【AtCoder】ARC092 D - Two Sequences

    [题目]AtCoder Regular Contest 092 D - Two Sequences [题意]给定n个数的数组A和数组B,求所有A[i]+B[j]的异或和(1<=i,j<=n ...

  2. 【Atcoder】CODE FESTIVAL 2017 qual A D - Four Coloring

    [题意]给定h,w,d,要求构造矩阵h*w满足任意两个曼哈顿距离为d的点都不同色,染四色. [算法]结论+矩阵变换 [题解] 曼哈顿距离是一个立着的正方形,不方便处理.d=|xi-xj|+|yi-yj ...

  3. 【AtCoder】ARC 081 E - Don't Be a Subsequence

    [题意]给定长度为n(<=2*10^5)的字符串,求最短的字典序最小的非子序列字符串. http://arc081.contest.atcoder.jp/tasks/arc081_c [算法]字 ...

  4. 【AtCoder】AGC022 F - Leftmost Ball 计数DP

    [题目]F - Leftmost Ball [题意]给定n种颜色的球各k个,每次以任意顺序排列所有球并将每种颜色最左端的球染成颜色0,求有多少种不同的颜色排列.n,k<=2000. [算法]计数 ...

  5. 【AtCoder】AGC005 F - Many Easy Problems 排列组合+NTT

    [题目]F - Many Easy Problems [题意]给定n个点的树,定义S为大小为k的点集,则f(S)为最小的包含点集S的连通块大小,求k=1~n时的所有点集f(S)的和取模92484403 ...

  6. 【AtCoder】ARC067 F - Yakiniku Restaurants 单调栈+矩阵差分

    [题目]F - Yakiniku Restaurants [题意]给定n和m,有n个饭店和m张票,给出Ai表示从饭店i到i+1的距离,给出矩阵B(i,j)表示在第i家饭店使用票j的收益,求任选起点和终 ...

  7. 【AtCoder】ARC095 E - Symmetric Grid 模拟

    [题目]E - Symmetric Grid [题意]给定n*m的小写字母矩阵,求是否能通过若干行互换和列互换使得矩阵中心对称.n,m<=12. [算法]模拟 [题解]首先行列操作独立,如果已确 ...

  8. 【Atcoder】AGC022 C - Remainder Game 搜索

    [题目]C - Remainder Game [题意]给定n个数字的序列A,每次可以选择一个数字k并选择一些数字对k取模,花费2^k的代价.要求最终变成序列B,求最小代价或无解.n<=50,0& ...

  9. 【Atcoder】AGC 020 B - Ice Rink Game 递推

    [题意]n个人进行游戏,每轮只保留最大的a[i]倍数的人,最后一轮过后剩余2人,求最小和最大的n,或-1.n<=10^5. [算法]递推||二分 [题解]令L(i),R(i)表示第i轮过后的最小 ...

随机推荐

  1. 【转】采用dlopen、dlsym、dlclose加载动态链接库

    1.前言 为了使程序方便扩展,具备通用性,可以采用插件形式.采用异步事件驱动模型,保证主控制逻辑不变,将各个业务以动态链接库的形式加载进来,这就是所谓的插件.linux提供了加载和处理动态链接库的系统 ...

  2. Linux中OCI开发库的配置

    Oracle调用接口(Oracle Call Interface,简称OCI)提供了一组可对Oracle数据库进行存取的接口子例程(函数),通过在第三代程序设计语言(如C语言)中进行调用可达到存取Or ...

  3. 一道搜索题【2013 noip提高组 DAY2 t3】华容道

    这篇不多说,具体的解释都在程序里 题目描述 [问题描述] 小 B 最近迷上了华容道,可是他总是要花很长的时间才能完成一次.于是,他想到用编程来完成华容道:给定一种局面, 华容道是否根本就无法完成,如果 ...

  4. TechnoSoftware OPCDA client(1.2.1) Error Codes

    OPCDA.NET Client Interface WrapperSummary of OPC Error Codes We have attempted to minimize the numbe ...

  5. #ifndef#define#endif的用法(整理)

    [转] #ifndef#define#endif的用法(整理)    原作者:icwk  文件中的#ifndef 头件的中的#ifndef,这是一个很关键的东西.比如你有两个C文件,这两个C文件都in ...

  6. HDU 5446

    题意: 大组合数取余 (素数连乘) 思路: 对于答案 X X % pi = ai === C(m,n) % pi: 然后就是用孙子定理求出X, ai 用 卢卡斯定理求得 中间 LL * LL 会爆, ...

  7. 修复ogg source端意外宕机造成的数据不同步

    修复ogg source端意外宕机造成的数据不同步 分类: Oracle2016-04-28 11:50:40原文地址:修复ogg source端意外宕机造成的数据不同步 作者:十字螺丝钉 ogg s ...

  8. Confluence 6 查看系统属性

    当你添加了内存,设置了代理(proxy)或者修改了 Java 的选项,通常比较难判断系统是否已经按照你的修改进行了配置和启动.这个页面将会帮助你查看 Confluence 站点运行使用的系统属性. 你 ...

  9. Confluence 6 数据库表-系统信息(System information)

    这些表格有存储数据相关的状态和 Confluence 站点的相关配置信息. confversion 被用来在升级系统的时候确定那个数据库的版本应该使用,这个表格只对数据库升级有影响. pluginda ...

  10. Confluence 6 配置 workbox 通知

    你可以在你的 Confluence workbox 中查看和管理应用内的通知和任务.更多的,你可以在 Confluence workbox 中从接收到从 JIRA 和其他 Confluence 服务器 ...