题意:

给你一个串只有小写字母和点,让你构造前缀是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【模拟构造】的更多相关文章

  1. 学习xss模拟构造攻击(第一篇)

    本文作者:i春秋签约作家——rosectow 0×00前言 XSS又名叫CSS全程(cross site scriptting),中文名跨站脚本攻击,目前网站的常见漏洞之一,它的危害没有像上传漏洞,s ...

  2. codeforces 1041 e 构造

    Codeforces 1041 E 构造题. 给出一种操作,对于一棵树,去掉它的一条边.那么这颗树被分成两个部分,两个部分的分别的最大值就是这次操作的答案. 现在给出一棵树所有操作的结果,问能不能构造 ...

  3. 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 ...

  4. 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 ...

  5. 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 ...

  6. 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 ...

  7. 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 ...

  8. 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 ...

  9. CodeForces - 1255D (模拟+构造+贪心)

    题意 https://vjudge.net/problem/CodeForces-1255D rxc的农场里'R'表示有米,现在有K只鸡,给这k只鸡选一些格子,每个鸡可以有多个格子(每个鸡至少吃一个米 ...

随机推荐

  1. Appium python自动化测试系列之认识Appium(四)

    ​4.1界面认识 在之前安装appium的时候说过我们有两种方法安装,也就有两种结果,一种是有界面的,一种是没有界面的,首先我们先讲一下有界面的,以及界面有哪些东西. 首先看第一幅图,如果你的是win ...

  2. iframe调用父页面js函数 方法 元素

    在一个页面中添加iframe,但是有时需要与父页面进行通信,传递参数. 网上总结有以下方法: 一.iframe标签中   src属性传参 <iframe src="test.jsp?i ...

  3. 在Qt Creator中创建C++工程并使用CMake构建项目

    创建完毕后,若电脑上没有安装CMake,则无法构建工程, 我用的是绿色版,官网下载地址:https://cmake.org/files/v3.10/cmake-3.10.1-win64-x64.zip ...

  4. System.IO.File类和System.IO.FileInfo类

    1.System.IO.File类 ※文件create, copy,move,SetAttributes,open,exists ※由于File.Create方法默认向所有用户授予对新文件的完全读写. ...

  5. 常用git命令和工具

    0. ln -s src_dir  //一个参数即可在当前目录下生成一个软链接   1.git command --clone/push a branch      git clone <url ...

  6. HDU4850 Wow! Such String! —— 字符串构造

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4850 代码如下: #include <iostream> #include <cst ...

  7. 自动化测试框架selenium+java+TestNG——TestNG详解

    TestNG按顺序执行case package com.testngDemo; import org.testng.annotations.AfterClass; import org.testng. ...

  8. Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stoc

    今天在使用yum安装文件时,出现了以下问题: root@localhost opt]# yum update Loaded plugins: fastestmirror Could not retri ...

  9. 让Outlook一直保持开启

    1.将OutLook.exe注册为服务,让其一直保持开启状态 类似于TaobaoProtect.exe是由TBSecSvc服务启动的 http://stackoverflow.com/question ...

  10. hibernate入门(-)

    1.struts2的支持 在web.xml中配置struts2的支持 <?xml version="1.0" encoding="UTF-8"?> ...