cf 766#
2024-09-02 09:58:34
天呢,太垃圾了我。。
AB懵逼了半天题意,C最后搞了个DP还不对。。。DP太垃圾了,,
#include<bits/stdc++.h>
#define INF 0x7fffffff
#define LL long long
#define N 100005
using namespace std;
inline int ra()
{
int x=,f=; char ch=getchar();
while (ch<'' || ch>'') {if (ch=='-') f=-; ch=getchar();}
while (ch>='' && ch<='') {x=x*+ch-''; ch=getchar();}
return x*f;
}
int main()
{
string s1,s2; cin>>s1>>s2;
if (s1.length()!=s2.length())
{
if (s1.length()>s2.length())
cout<<s1.length();
else cout<<s2.length();
}
else
{
if (s1==s2) cout<<"-1";
else cout<<s1.length();
}
return ;
}
#include<bits/stdc++.h>
#define INF 0x7fffffff
#define LL long long
#define N 100005
using namespace std;
inline int ra()
{
int x=,f=; char ch=getchar();
while (ch<'' || ch>'') {if (ch=='-') f=-; ch=getchar();}
while (ch>='' && ch<='') {x=x*+ch-''; ch=getchar();}
return x*f;
}
int a[N];
int main()
{
int n=ra();
for (int i=; i<=n; i++) a[i]=ra();
sort(a+,a+n+);
for (int i=; i<=n-; i++)
{
if (a[i]+a[i+]>a[i+] && a[i+]-a[i]<a[i+])
{
cout<<"YES";
return ;
}
}
cout<<"NO";
return ;
}
/*#include<bits/stdc++.h>
#define INF 0x7fffffff
#define LL long long
#define N 100005
using namespace std;
inline LL ra()
{
LL x=0,f=1; char ch=getchar();
while (ch<'0' || ch>'9') {if (ch=='-') f=-1; ch=getchar();}
while (ch>='0' && ch<='9') {x=x*10+ch-'0'; ch=getchar();}
return x*f;
}
bool vis[1005][1005];
LL n,f[1005][1005],a[50],anslen;
char s[1005];
const LL mod=1e9+7;
int main()
{
n=ra(); scanf("%s",s+1);
for (LL i=0; i<26; i++) a[i]=ra();
LL mn=INF;
for (LL i=1; i<=n; i++)
{
mn=min(mn,a[s[i]-'a']);
if (mn<i) break;
f[i][1]=1;
vis[i][1]=1;
anslen=max(anslen,i);
}
for (LL i=1; i<=n; i++)
{
for (LL j=2; j<=i; j++)
{
LL mn=a[s[i]-'a'],cnt=1;
for (LL k=i-1; k>=1; k--,cnt++)
{
mn=min(mn,a[s[k]-'a']);
if (mn<cnt) break;
f[i][j]+=f[k][j-1];
if (vis[k][j-1]) vis[i][j]=1;
f[i][j]%=mod;
if (vis[k][j-1]) anslen=max(anslen,cnt);
}
}
}
LL anstot=0,ansnum;
for (LL i=1; i<=n; i++) anstot+=f[n][i],anstot%=mod;
cout<<anstot<<endl;
for (LL i=1; i<=n; i++)
if (f[n][i])
{
ansnum=i;
break;
}
cout<<anslen<<endl<<ansnum;
return 0;
}*/
#include<bits/stdc++.h>
#define INF 0x7fffffff
#define LL long long
#define N 100005
using namespace std;
inline LL ra()
{
LL x=,f=; char ch=getchar();
while (ch<'' || ch>'') {if (ch=='-') f=-; ch=getchar();}
while (ch>='' && ch<='') {x=x*+ch-''; ch=getchar();}
return x*f;
}
int f[N],n,dp[N],a[N],mx;
char s[N];
const int mod=1e9+;
bool check(int i, int j)
{
int l=j-i+;
for (int k=i; k<=j; k++)
{
if (a[s[k]-'a']<l)
return ;
}
return ;
}
int main()
{
n=ra(); scanf("%s",s+);
for (int i=; i<; i++) a[i]=ra();
memset(f,0x3f,sizeof(f));
dp[]=; f[]=;
for (int i=; i<=n; i++)
for (int j=; j<=i; j++)
if (check(i-j+,i))
{
dp[i]=(dp[i]+dp[i-j])%mod;
f[i]=min(f[i],f[i-j]+);
if (dp[i-]) mx=max(mx,j);
}
cout<<dp[n]<<endl;
cout<<mx<<endl;
cout<<f[n]<<endl;
}
最新文章
- C++基础知识易错点总结(2)
- Trie树的创建、插入、查询的实现
- Chart系列(一):Chart的基本元素
- 使用公司自己的maven服务器时,本地 maven 的配置方法
- MyFramework框架搭建(二)DAL层整体通信
- 【狼】unity3d point light 个数限制更改
- Linux开发工具之gdb(上)
- [原创]Python入门到简单网站目录扫描器编写(上)
- 论文阅读 | CrystalBall: A Visual Analytic System for Future Event Discovery and Analysis from Social Media Data
- Java 基础系列合集
- MySQL的SQL语句
- Tushare数据的绘图操作
- redmine生产环境搭建
- Debian防御DDOS(简易版本)
- HTTPS复习
- 关于iframe中使用fixed定位的一些问题
- 聚合的安全类导航、专业的安全知识学习平台——By Me:)
- 网站部署中遇到的问题-网页中js,css和图片资源无法加载
- hdu4757(可持久化 Trie )
- 5.设计模式----prototype原型模式
热门文章
- MySQL 加密 压缩
- Jquery事件汇总、网页入口
- 使用Vue 和 内网穿透:返回 invalid host header
- PLCsim 软件模拟OB86故障
- HihoCoder第三周与POJ2406:KMP算法总结
- eclipse springboot运行helloworld错误: 找不到或无法加载主类 xxx.xxx.xxx
- UAC绕过初探
- C++中数字与字符串之间的转换 scanf string总结(复习必读)
- Dubbo的配置过程,实现原理及架构详解
- Django(五)1 - 4章实战:从数据库读取图书列表并渲染出来、通过url传参urls.py path,re_path通过url传参设置、模板语法