Codeforces 538 A Cutting Banner

Win10/Win11系统下,用VSCode编译Betaflight固件最全避坑指南(从GCC安装到HEX生成) 本文详细介绍了在Win10/Win11系统下使用VSCode编译Betaflight固件的完整流程,包括GCC安装、环境变量配置、终端选择、Make工具安装等关键步骤,帮助开发者避开常见陷阱,高效生成HEX文件。特别针对VSCode环境优化和编译错误排查提供了实用解决方案。 阅读详情
codeforces 538 A Cutting Banner
题目链接:
A. Cutting Banner
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

A large banner with word CODEFORCES was ordered for the 1000-th onsite round of Codeforcesω that takes place on the Miami beach. Unfortunately, the company that made the banner mixed up two orders and delivered somebody else's banner that contains someone else's word. The word on the banner consists only of upper-case English letters.

There is very little time to correct the mistake. All that we can manage to do is to cut out some substring from the banner, i.e. several consecutive letters. After that all the resulting parts of the banner will be glued into a single piece (if the beginning or the end of the original banner was cut out, only one part remains); it is not allowed change the relative order of parts of the banner (i.e. after a substring is cut, several first and last letters are left, it is allowed only to glue the last letters to the right of the first letters). Thus, for example, for example, you can cut a substring out from string 'TEMPLATE' and get string 'TEMPLE' (if you cut out string AT), 'PLATE' (if you cut out TEM), 'T' (if you cut out EMPLATE), etc.

Help the organizers of the round determine whether it is possible to cut out of the banner some substring in such a way that the remaining parts formed word CODEFORCES.

Input

The single line of the input contains the word written on the banner. The word only consists of upper-case English letters. The word is non-empty and its length doesn't exceed 100 characters. It is guaranteed that the word isn't word CODEFORCES.

Output

Print 'YES', if there exists a way to cut out the substring, and 'NO' otherwise (without the quotes).

Examples
input
CODEWAITFORITFORCES
output
YES
input
BOTTOMCODER
output
NO
input
DECODEFORCES
output
YES
input
DOGEFORCES
output
NO

题目大意:输入一个长度不超过100的字符串,问能不能删除一个子串得到"CODEFORCES"这个字符串(只能删一次)

思路:这道题想了很久也没想到一个好的解决方法,后来看了cf上的大神的代码,大多数大概就是用了c++函数库里的一个substr()函数(查找子串函数)很简明的一段代码完成的,还有一种就是直接暴力先一层循环找前i个子串,然后从i到length-1找后面的子串,看这两部分连接后能不能构成所求字符串。

代码1:
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;

#define m(a,b) memset(a,b,sizeof(a))
#define debug(x) cerr<<#x<<"="<<x<<endl;
typedef long long ll;

int main(){
	string s;
	while(cin>>s){
		int l=s.size();
		bool flag=false;
		for(int i=0;i<l;i++){
			for(int j=0;j<l;j++){
				if (s.substr(0,i)+s.substr(j+1)=="CODEFORCES")
					flag=true;
			}
		}
		if (flag) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}
代码2:
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;

#define m(a,b) memset(a,b,sizeof(a))
#define debug(x) cerr<<#x<<"="<<x<<endl;
typedef long long ll;

int main(){
	string s;
	while(cin>>s){
		int l=s.size();
		bool flag=false;
		for(int i=0;i<l;i++){
			for(int j=i;j<l;j++){
				string s1;
				for(int k=0;k<i;k++)
					s1+=s[k];
				for(int k=j+1;k<l;k++)
					s1+=s[k];
				if (s1=="CODEFORCES"){
					flag=true;
					break;
				}
			}
		}
		if (flag) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	return 0;
}



基于昇腾MindIE开箱部署Qwen2.5-VL-32B,体验更聪明的多模态理解能力 昇腾MindIE已适配支持Qwen2.5-VL-32B-Instruct并上架魔乐社区,欢迎广大开发者下载体验! 阅读详情

相关推荐

ROS2节点通信实战:用C++手写一个‘智能小车’控制模型(附完整代码)

本文详细介绍了如何使用ROS2和C++构建一个智能小车控制模型,涵盖运动控制节点、电池管理服务、参数动态配置和Rviz可视化等核心功能。通过实战项目演示ROS2节点通信机制,帮助开发者快速掌握机器人开发的关键技术,并提供了完整的代码实现和系统集成方案。

weixin_30607029的博客 272

C - Cutting Banner

A large banner with word CODEFORCES was ordered for the 1000-th onsite round of Codeforcesω that takes place on the Miami beach. Unfortunately, the company that made the banner mixed up two orders and...

qq_45147137的博客 337

实战指南:用Python实现ONVIF WS-Discovery设备发现(附完整代码)

本文提供了一份详细的实战指南,介绍如何使用Python实现基于ONVIF标准的WS-Discovery设备发现协议。文章深入解析了协议原理、网络通信模型,并提供了完整的代码实现,帮助开发者快速构建智能安防和物联网应用中的设备自动发现工具,有效提升网络设备集成与管理的效率。

chair的专栏 1127

Cutting_Banner(暴力)

传送门 题意:给你个字符串,减去一段子串,是否能将剩下的不改变顺序拼成"CODEFORCES",能则输出"YES",否则输出"NO" 思路:直接枚举减去的长度,然后暴力 代码如下 #include <algorithm> #include <cstdio> #include <cstring> #include <string> #include <vector> using namespace std; char aim[] = "COD

hao_6_6的博客 382

ZEMAX学习 6.一个照相物镜的设计

曲线越平滑表示场曲越小,曲线越接近水平,系统边缘与中心对比度越接近,虚实越接近表示色差和色散越好;第1个面设计不合理,出现前后表面相交的情况,点击第1面厚度,选择边缘厚度,设置为0.1,第1面厚度被控制在0.1mm厚,系统根据这一设置始终保持第1面边缘厚度为0.1mm。要求:设计一个照相物镜,焦距f=9mm,F#为4,视场角40°;添加有效焦距操作数EFFL 9mm 权重为1,设置优化变量,如下图,ctrl+shift+o打开优化界面。报告中系统数据有效焦距为67.381mm,设计要求为9mm;

qq_24542783的博客 4718

Unity游戏开发客户端面经——数据结构(初级)

Unity游戏开发客户端面经 之 数据结构篇

Sea3752的博客 1万+

codeforces #300 A. Cutting Banner

题意: 给定一个字符串,找出能否找出【一个】【连续】的串,从串中删掉,然后剩下的串只剩下【CODEFORCES】。 是则输出YES,否则输出NO 思路: 穷举删除的区间,查看剩下的串是否是【CODEFORCES】即可。 我穷举的区间是[i,j) 区间(注意开闭符号), 对 【CODEFORCESXXXXXXX】这样的串先判定一下即可。 蓝桥杯要开始了,刷一波JAV

ACMer不要报考高校代码为13627的移通学院! 442

告别降级CUDA!手把手教你为RTX 50系显卡(5080/5090)配置专属的PyTorch Nightly + vLLM推理环境

本文详细指导如何为RTX 50系显卡(5080/5090)配置专属的PyTorch Nightly和vLLM推理环境,特别针对CUDA 12.8的适配问题提供解决方案。从硬件准备到源码编译,再到模型部署与性能调优,手把手教你构建高效AI推理系统。

weixin_33724046的博客 412

Cutting Banner

思路:没有思路。没有理解题意。不知道只剪一次,废了很多时间结果只需要分别从前边从后边比较。 代码: #include"cstdio" #include"algorithm" #include"set" #include"cmath" #include"cstring" using namespace std; int main() { char s[105]; char t[12]=“CODE...

cest123的博客 266

PX4笔记系列(二)vtol_att_control中的tiltrotor解析

update_vtol_state() 注释:采用两段切换的简单逻辑来进行过渡 当切换过渡开关后,飞机将会开始倾转动力,逐渐加速,当飞机获得足够速度后动力将会完全打到向前的位置。对于过渡返回阶段动力则是简单地倾转回来。 如果(不在向前过渡指令下): 当前vtol飞行模式: 1、旋翼模式 无操作 2、固定翼模式 令vtol飞行模式切换到过渡返回模式 3、P1过渡模式 进入过渡失败安全返回至旋翼模式 4、P2过渡模式 进入过渡失败安全返回至旋翼模式 5、过渡返回模式 记录过渡返回时间=当前时间-过渡开始

hypersonicss的博客 1884

在Rviz仿真环境中搭建传送带

<geometry><material>

qq_58268456的博客 949

CodeForces 538 A.Cutting Banner(水~)

Description 切去一个字符串的某个子串后问剩余部分是否可能是CODEFORCES Input 一个字符串 Output 如果切去某个子串后可以变成CODEFORCES则输出YES,否则输出NO Sample Input DECODEFORCES Sample Output YES Solution 从字符串两端分别与目标串进行匹配直至不能匹配,记录匹配终点res1,...

ZSQ 555

基于深度学习的火焰检测系统:YOLOv8 + UI界面 + 数据集详解

YOLO(You Only Look Once)是一种端到端的目标检测算法,其最大优势在于将目标检测任务转化为一个回归问题,可以在一次前向传播中同时完成目标定位和分类。YOLOv8是YOLO系列中的最新版本,相比之前的版本,YOLOv8在精度和推理速度上都做了显著提升,特别是在小物体检测方面表现更加优秀。实时性:YOLOv8具有较高的推理速度,适用于实时火焰检测。高精度:相较于YOLOv7,YOLOv8在精度和小物体检测上有所改进。简单易用:YOLOv8的API简单直观,易于集成和使用。

YOLO 668

codeforces 538 A.Cutting Banner

A. Cutting Banner time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A large banner with word CODEFORCES was o

ysCover 1132

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

codeforces 538 A Cutting Banner

A. Cutting Banner time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A large banner with word CODEFORCES was o

Han_kin的专栏 684

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

CodeForces - 538A Cutting Banner解题报告

题目大意:给你一个字符串,让你判断能否通过删除该字符串的一个子串,得到字符串 “CODEFORCES”。

薛崇祥的博客 546

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

C - Cutting Banner CodeForces - 538A

A large banner with word CODEFORCES was ordered for the 1000-th onsite round of Codeforcesω that takes place on the Miami beach. Unfortunately, the company that made the banner mixed up two orders and...

云乐 315

Codeforces 538 A. Cutting Banner-substr()函数字符串拼接

A. Cutting Banner time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A large banner with word CODEFORCES was ord...

weixin_30251587的博客 98

A538: Cutting Banner

题目链接:http://codeforces.com/contest/538/problem/Aimport java.util.Scanner; public class A538 { void solve(){ Scanner in=new Scanner(System.in); String str=in.next(); String cf

水滴石穿 897

洛谷 CF538A Cutting Banner 题解

给定只由大写英文字母组成的字符串 s(长度不超过100),问删掉几个连续的字符(即删去一个子串)之后是否能得到。既然长度不超过100,那么可以双重循环暴力。最后把两边保留的字符拼起来看一下是不是。,枚举的是保留左边的。,枚举的是保留右边的。

lhschris的博客 434

538A - Cutting Banner

切一段看是否可以组成"CODEFORCES",一个sunstr函数的应用。。。#include #include #include #include #include using namespace std; int main() { string s; while(cin>>s) { int str=s.length(); for(int

Mosu_的专栏 653

A - Cutting Banner(substr()函数)four

题目链接:http://codeforces.com/problemset/problem/538/A解题思路:    several consecutive letters.(可以使用substr()函数)在使用该函数的时候,需要注意:其截取子串的方向为从左到右。最后运行程序的时候,还是runtime error,因此自己检查后发现循环次数只需控制在i &lt;= 10即可。实现代码:#incl...

Lucky_-的博客 378

CF 538A(Cutting Banner-暴力找切割点)

A. Cutting Banner time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A large banner with word CODEFORCES was o

nike0good |Oier&ACMer | 熟能生巧 1783

codeforces 538A

出题人红果果的秀了一回英语“it is possible to cut out of the banner some substring in such a way”,“some substring”的意思是某个子串,“some substrings”才是一些子串OTZ。 题目大意:给一个字符串,从中减去一个子串,是否能变成“CODEFORCES”,水题水水的过,要变成“CODEFORCES

发神经的猫的专栏 854

Codeforces Round #300 A. Cutting Banner 水题

A. Cutting Banner Time Limit: 1 SecMemory Limit: 256 MB 题目连接 http://codeforces.com/contest/538/problem/A Description A large banner with word CODEFORCES was ordered for the 1000-th onsi...

weixin_30245867的博客 89

Codeforces #300 A

A. Cutting Banner time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A large banner with word CODEFORCES was o

qq_27291877的博客 332
上一篇: codeforces 157B Trace
下一篇: C++的输入输出与C的输入输出比较
_dingzhen
博客等级 码龄9年 120粉丝 44原创
评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址