A - 【The__Flash】的矩阵

给你一个m×n的整数矩阵,在上面找一个x×y的子矩阵,使子矩阵中所有元素的和最大。

Input输入数据的第一行为一个正整数T,表示有T组测试数据。每一组测试数据的第一行为四个正整数m,n,x,y(0<m,n<1000 AND 0<x<=m AND 0<y<=n),表示给定的矩形有m行n列。接下来这个矩阵,有m行,每行有n个不大于1000的正整数。Output对于每组数据,输出一个整数,表示子矩阵的最大和。

Sample Input

1
4 5 2 2
3 361 649 676 588
992 762 156 993 169
662 34 638 89 543
525 165 254 809 280 Sample Output
2474

思路:

二维前缀和

 #include <iostream>
#include <algorithm>
#include <cstdio>
int t,m,n,x,y,a[][],dp[][];
using namespace std;
int main()
{ cin>>t;
while(t--)
{
cin>>m>>n>>x>>y;
for(int i=;i<=m;i++)
for(int j=;j<=n;j++)
{
cin>>a[i][j];
}
for(int i=;i<=m;i++)
for(int j=;j<=n;j++)
{
dp[i][j]=a[i][j]+dp[i][j-]+dp[i-][j]-dp[i-][j-];
}
long long ans=;
for(int i=;i<=m-x;i++)
for(int j=;j<=n;j++)
{
long long ii=i+x-,jj=j+y-;
long long t=dp[ii][jj]-dp[i-][jj]-dp[ii][j-]+dp[i-][j-];
ans=max(ans,t);
}
cout<<ans<<endl;
}
}

G - 【The__Flash】的水题

You are given two strings of equal length ss and tt consisting of lowercase Latin letters. You may perform any number (possibly, zero) operations on these strings.

During each operation you choose two adjacent characters in any string and assign the value of the first character to the value of the second or vice versa.

For example, if ss is "acbc" you can get the following strings in one operation:

  • "aabc" (if you perform s2=s1s2=s1 );
  • "ccbc" (if you perform s1=s2s1=s2 );
  • "accc" (if you perform s3=s2s3=s2 or s3=s4s3=s4 );
  • "abbc" (if you perform s2=s3s2=s3 );
  • "acbb" (if you perform s4=s3s4=s3 );

Note that you can also apply this operation to the string tt .

Please determine whether it is possible to transform ss into tt , applying the operation above any number of times.

Note that you have to answer qq independent queries.

Input

The first line contains one integer qq (1≤q≤1001≤q≤100 ) — the number of queries. Each query is represented by two consecutive lines.

The first line of each query contains the string ss (1≤|s|≤1001≤|s|≤100 ) consisting of lowercase Latin letters.

The second line of each query contains the string tt (1≤|t|≤1001≤|t|≤100 , |t|=|s||t|=|s| ) consisting of lowercase Latin letters.

Output

For each query, print "YES" if it is possible to make ss equal to tt , and "NO" otherwise.

You may print every letter in any case you want (so, for example, the strings "yEs", "yes", "Yes", and "YES" will all be recognized as positive answer).

Example

Input
3
xabb
aabx
technocup
technocup
a
z
Output
YES
YES
NO

Note

In the first query, you can perform two operations s1=s2s1=s2 (after it ss turns into "aabb") and t4=t3t4=t3 (after it tt turns into "aabb").

In the second query, the strings are equal initially, so the answer is "YES".

In the third query, you can not make strings ss and tt equal. Therefore, the answer is "NO".

 #include <iostream>
#include <string>
using namespace std;
int main()
{
int n;
string s,t;
cin>>n;
while(n--)
{
cin>>s>>t;
int ls=s.size();
int w=;
for(int i=;i<ls;i++)
{
for(int j=;j<ls;j++)
if(s[i]==t[j])
{
w=;
break;
}
}
if(w==)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
} }

J - 【The__Flash】的球球

N个气球排成一排,从左到右依次编号为1,2,3....N.每次给定2个整数a b(a <= b),lele便为骑上他的“小飞鸽"牌电动车从气球a开始到气球b依次给每个气球涂一次颜色。但是N次以后lele已经忘记了第I个气球已经涂过几次颜色了,你能帮他算出每个气球被涂过几次颜色吗?

Input每个测试实例第一行为一个整数N,(N <= 100000).接下来的N行,每行包括2个整数a b(1 <= a <= b <= N)。
当N = 0,输入结束。Output每个测试实例输出一行,包括N个整数,第I个数代表第I个气球总共被涂色的次数。Sample Input

3
1 1
2 2
3 3
3
1 1
1 2
1 3
0

Sample Output

1 1 1
3 2 1 一维前缀和
 #include <iostream>
#include <cstdio>
using namespace std;
int main()
{
int n,a,b;
while(scanf("%d",&n)!=EOF)
{
if(n==) return ;
int m[]={};
int t=n;int s=;
while(n--)
{
cin>>a>>b;
m[a]++;m[b+]--; }
for(int i=;i<=t;i++)
{
s+=m[i];
cout<<s;
printf("%c",i==t?'\n':' ');
}
} }

SDNU_ACM_ICPC_2020_Winter_Practice_2nd的更多相关文章

随机推荐

  1. Codeforces Round #621 (Div. 1 + Div. 2)E(二分查找,枚举分界点,容斥原理)

    可以把每头牛看作一个位置,有几对牛可以放置相当于有几对位置可以给它睡觉,没有牛可以在其他牛的位置睡觉,所以有几对牛放置的可能答案就乘多少(相当于在原本的两个集合里分别插入一个元素,元素代表它睡觉的位置 ...

  2. Runtime.getRuntime.exec()执行linux脚本导致程序卡死有关问题

    Runtime.getRuntime.exec()执行linux脚本导致程序卡死问题问题: 在Java程序中,通过Runtime.getRuntime().exec()执行一个Linux脚本导致程序被 ...

  3. 【转载】Hadoop Hive基础sql语法

    转自:http://www.cnblogs.com/HondaHsu/p/4346354.html Hive 是基于Hadoop 构建的一套数据仓库分析系统,它提供了丰富的SQL查询方式来分析存储在H ...

  4. Charles 查看https请求数据 Mac/ android

    Charles_v4.0.1_Mac_破解版下载地址:https://pan.baidu.com/s/1c23VPuS 1.在Mac电脑上安装Charles的根证书 打开Charles->菜单H ...

  5. Python获取最新电影的信息

    这次将从电影天堂获取最新的电影的详细信息,这里电影的信息罗列的比较详细. 本来只是想获取电影的迅雷链接,然后用迅雷去下载.但看到这里的电影的信息比较完整和详细,忍不住把所有信息都爬取下来了. 下图是& ...

  6. 用navicate 连接本地数据库提示用户名/口令无效

    1.在用navicate连接本地的oracle数据库时,试了oracle几个默认的用户名和密码,但是当我输入时,却提示用户名/口令无效.所以按照网上的办法,cmd,输入了以下命令,修改了几个用户的用户 ...

  7. java.util.UUID工具类

    生成数据表的主键Id会用到此工具类 /** * <获取主鍵> * <获取32位UUID> * @return * @see [类.类#方法.类#成员] */ public st ...

  8. 普及C组第三题(8.10)

    2301. [普及组T3或T4]线索 (File IO): input:assassin.in output:assassin.out 时间限制: 1000 ms  空间限制: 262144 KB 题 ...

  9. Ninject 2.x细说---2.绑定和作用域

    Ninject 2.x细说---2.绑定和作用域 转载weixin_33725272 最后发布于2011-11-06 00:03:00 阅读数 9  收藏   Ninject中提供多种接口和实现类的绑 ...

  10. pikachu练习平台(XSS-漏洞测试案例(cookie的窃取和利用、钓鱼攻击、XSS获取键盘记录))

    XSS-漏洞测试案例 xss案例 1.cookie的窃取和利用 2.钓鱼攻击 3.XSS获取键盘记录 在进行案例之前首先要搭建xss后台 搭建xss后台 1.在pikachu文件夹下面,把pkxss单 ...