Codeforces 174B【模拟构造】
题意:
给你一个串只有小写字母和点,让你构造前缀是1-8,后缀是1-3长度的文件名;
思路:
那么以"."作为分割点,把字符串都拿出来,然后
首段长度<=8 OK;
中间<=11 OK;
尾段<=3 OK;
否则都不行;
啊,水题啊,wa了一次,T了一次,神TM都是数据开小了,
一个是4e5写成5e4。。。
一个是不满足的情况可能会很长,才开了。。。25...
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int>PII;
const double eps=1e-5;
const double pi=acos(-1.0);
const int INF=0x3f3f3f3f; const int N=4e5+10;
struct asd
{
int length;
char tep[50];
};
int num;
asd q[N];
char s[N]; char ans[N][50];
char temp[N]; int main()
{
int temp_num;
scanf("%s",s);
int len=strlen(s);
bool flag=false;
num=0;
temp_num=0;
for(int i=0; i<len; i++)
{
if(s[i]=='.')
{
if(!flag)
{
if(temp_num>8||!temp_num)
{
puts("NO");
return 0;
}
temp[temp_num]='\0';
strcpy(q[num].tep,temp);
q[num].length=temp_num;
num++;
flag=true;
}
else
{
if(temp_num>11||temp_num<2)
{
puts("NO");
return 0;
}
temp[temp_num]='\0';
strcpy(q[num].tep,temp);
q[num].length=temp_num;
num++;
}
temp_num=0;
}
else
temp[temp_num++]=s[i];
}
if(!temp_num||temp_num>3||!flag)
{
puts("NO");
return 0;
}
temp[temp_num]='\0';
strcpy(q[num].tep,temp);
q[num].length=temp_num;
num++;
int kp=0;
int ans_num=0;
int pp=0;
for(int i=1;i<num;i++)
{
pp=0;
for(int j=kp;j<q[i-1].length;j++)
ans[ans_num][pp++]=q[i-1].tep[j];
ans[ans_num][pp++]='.';
if(q[i].length>3)
kp=3;
else
kp=1;
if(i==num-1)
kp=q[i].length;
for(int j=0;j<kp;j++)
ans[ans_num][pp++]=q[i].tep[j];
ans[ans_num][pp]='\0';
ans_num++;
}
puts("YES");
for(int i=0;i<ans_num;i++)
printf("%s\n",ans[i]);
return 0;
}
Codeforces 174B【模拟构造】的更多相关文章
- 学习xss模拟构造攻击(第一篇)
本文作者:i春秋签约作家——rosectow 0×00前言 XSS又名叫CSS全程(cross site scriptting),中文名跨站脚本攻击,目前网站的常见漏洞之一,它的危害没有像上传漏洞,s ...
- codeforces 1041 e 构造
Codeforces 1041 E 构造题. 给出一种操作,对于一棵树,去掉它的一条边.那么这颗树被分成两个部分,两个部分的分别的最大值就是这次操作的答案. 现在给出一棵树所有操作的结果,问能不能构造 ...
- Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) A B C D 水 模拟 构造
A. Neverending competitions time limit per test 2 seconds memory limit per test 512 megabytes input ...
- Codeforces 791C. Bear and Different Names 模拟构造
C. Bear and Different Names time limit per test:1 second memory limit per test:256 megabytes input:s ...
- Codeforces Round #350 (Div. 2) F. Restore a Number 模拟构造题
F. Restore a Number Vasya decided to pass a very large integer n to Kate. First, he wrote that num ...
- Codeforces 798C. Mike and gcd problem 模拟构造 数组gcd大于1
C. Mike and gcd problem time limit per test: 2 seconds memory limit per test: 256 megabytes input: s ...
- Codeforces 960 二进制构造子序列 完全二叉树shift模拟 主席树/MAP DP
A #include <bits/stdc++.h> #define PI acos(-1.0) #define mem(a,b) memset((a),b,sizeof(a)) #def ...
- Codeforces Round #372 (Div. 2) A B C 水 暴力/模拟 构造
A. Crazy Computer time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...
- CodeForces - 1255D (模拟+构造+贪心)
题意 https://vjudge.net/problem/CodeForces-1255D rxc的农场里'R'表示有米,现在有K只鸡,给这k只鸡选一些格子,每个鸡可以有多个格子(每个鸡至少吃一个米 ...
随机推荐
- EasyRTSPClient:基于live555封装的支持重连的RTSP客户端RTSPClient
今天先简单介绍一下EasyRTSPClient,后面的文章我们再仔细介绍EasyRTSPClient内部的设计过程: EasyRTSPClient:https://github.com/EasyDar ...
- splittability A SequenceFile can be split by Hadoop and distributed across map jobs whereas a GZIP file cannot be.
splittability CompressedStorage Skip to end of metadata Created by Confluence Administrator, l ...
- Qt笔记之使用设计器自定义窗口标题栏
1.在窗口显示之前,设置WindowFlags为FramelessWindowHint,以产生一个没有边界的窗口 例如 Widget::Widget(QWidget *parent) : QWidge ...
- [Spring Batch 系列] 第一节 初识 Spring Batch
距离开始使用 Spring Batch 有一段时间了,一直没有时间整理,现在项目即将完结,整理下这段时间学习和使用经历. 官网地址:http://projects.spring.io/spring-b ...
- appium(11)-java-client
Welcome to the Appium Java client wiki! This framework is an extension of the Selenium Java client. ...
- appium(4)-Automating mobile web apps
Automating mobile web apps If you’re interested in automating your web app in Mobile Safari on iOS o ...
- 高精度乘法(FFT)
学会了FFT之后感觉自己征服了世界! 当然是幻觉... 不过FFT还是很有用的,在优化大规模的动规问题的时候有极大效果. 一般比较凶残的计数动规题都需要FFT(n<=1e9). 下面是高精度乘法 ...
- bzoj4485: [Jsoi2015]圈地
思维僵化选手在线被虐 其实应该是不难的,题目明显分成两个集合,要求是不同集合的点不能联通 先假设全选了,然后二分图最小割,相邻两个点直接连墙的费用就可以了 #include<cstdio> ...
- 将linux系统用户导入mysql表
下面这个程序实现的一个很简单的功能,读取passwd文件,将里面的用户信息写入到mysql里面, 具体代码如下: #!/usr/bin/python import pymysql import tim ...
- codevs 3324 新斯诺克
3324 新斯诺克 时间限制: 1 s 空间限制: 64000 KB 题目等级 : 白银 Silver 题目描述 Description 斯诺克又称英式台球,是一种流行的台球运动.在球桌上, ...