传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=4839

【题解】

pkusc怎么出bzoj原题啊

字符串随便处理一下就行了,大模拟

pkusc:2A(freopen调试没删)

线下:2A(数组不够大)

# include <stdio.h>
# include <string.h>
# include <iostream>
# include <algorithm>
// # include <bits/stdc++.h> using namespace std; typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int M = 5e5 + ;
const int mod = 1e9+; # define RG register
# define ST static char str[]; char s[][];
int sn = ;
char t[];
char ans[];
int tn = , n = ; inline bool isok(int i) {
if(!isupper(s[i][])) return ;
int len = strlen(s[i]);
if(len == ) return ;
for (int j=; j<len; ++j)
if(!islower(s[i][j])) return ;
return ;
} inline bool isBlank(int i) {
int len = strlen(s[i]);
if(len != ) return ;
return s[i][] == ' ';
} int main() {
// freopen("bzoj4839.in", "r", stdin);
while(cin.getline(str, )) {
int len = strlen(str);
sn = ;
for (int i=; i<len; ++i) {
if(isupper(str[i]) || islower(str[i])) {
tn = ;
int j = i;
while(isupper(str[j]) || islower(str[j])) {
t[tn++] = str[j];
++j;
}
++sn;
for (int j=; j<tn; ++j)
s[sn][j] = t[j];
s[sn][tn] = ;
i = j-;
} else {
++sn; s[sn][] = str[i];
s[sn][] = ;
}
}
// for (int i=1; i<=sn; ++i) printf("%s==\n", s[i]);
n = ;
for (int i=; i<=sn; ++i) {
if(!isok(i)) {
for (int j=; s[i][j]; ++j)
ans[n++] = s[i][j];
} else {
int j = i;
while(j+ <= sn && isBlank(j+) && isok(j+)) j += ;
if(j == i) {
for (int k=; s[i][k]; ++k)
ans[n++] = s[i][k];
} else {
for (int k=i; k<=j; k+=)
ans[n++] = s[k][];
ans[n++] = ' ';
ans[n++] = '(';
for (int k=i; k<=j; k++)
for (int l=; s[k][l]; ++l)
ans[n++] = s[k][l];
ans[n++] = ')';
i = j;
}
}
}
ans[n] = ;
printf("%s\n", ans);
}
return ;
}

bzoj4839 [Neerc2016]Abbreviation的更多相关文章

  1. [LeetCode] Minimum Unique Word Abbreviation 最短的独一无二的单词缩写

    A string such as "word" contains the following abbreviations: ["word", "1or ...

  2. [LeetCode] Valid Word Abbreviation 验证单词缩写

    Given a non-empty string s and an abbreviation abbr, return whether the string matches with the give ...

  3. [LeetCode] Unique Word Abbreviation 独特的单词缩写

    An abbreviation of a word follows the form <first letter><number><last letter>. Be ...

  4. Leetcode: Minimum Unique Word Abbreviation

    A string such as "word" contains the following abbreviations: ["word", "1or ...

  5. Leetcode: Valid Word Abbreviation

    Given a non-empty string s and an abbreviation abbr, return whether the string matches with the give ...

  6. 411. Minimum Unique Word Abbreviation

    A string such as "word" contains the following abbreviations: ["word", "1or ...

  7. Leetcode Unique Word Abbreviation

    An abbreviation of a word follows the form <first letter><number><last letter>. Be ...

  8. 288. Unique Word Abbreviation

    题目: An abbreviation of a word follows the form <first letter><number><last letter> ...

  9. [Locked] Unique Word Abbreviation

    Unique Word Abbreviation An abbreviation of a word follows the form <first letter><number&g ...

随机推荐

  1. php 使用GD库压缩图片,添加文字图片水印

    先上一个工具类,提供了压缩,添加文字.图片水印等方法: image.class.php <?php class Image { private $info; private $image; pu ...

  2. C#文件重命名的代码

    C#中没有重命名的方法,自己写了一个方法,来处理文件的重命名. /// <summary> /// 重命名文件夹内的所有子文件夹 /// </summary> /// < ...

  3. 【赛后补题】(HDU6223) Infinite Fraction Path {2017-ACM/ICPC Shenyang Onsite}

    场上第二条卡我队的题目. 题意与分析 按照题意能够生成一个有环的n个点图(每个点有个位数的权值).图上路过n个点显然能够生成一个n位数的序列.求一个最大序列. 这条题目显然是搜索,但是我队在场上(我负 ...

  4. cf#513 B. Maximum Sum of Digits

    B. Maximum Sum of Digits time limit per test 2 seconds memory limit per test 512 megabytes input sta ...

  5. Qt C++ 并发,并行,多线程编程系列1 什么是并发

    什么是并发,并发往简单来说就是两个或多个独立的任务同时发生,在我们的生活中也是随处可见.如果把每个人都当作一个独立的任务,那每个人可以相互独立的生活,这就是并发. 在计算机的系统里面,并发一般有两种, ...

  6. CSS : @media 示例

    .example { padding: 20px; color: white; } /* Extra small devices (phones, 600px and down) */ @media ...

  7. 5.爬虫 requests库讲解 高级用法

    0.文件上传 import requests files = {'file': open('favicon.ico', 'rb')} response = requests.post("ht ...

  8. 关于Scala文件操作中出现的问题

    在各种项目中,我们常常需要用到文件操作,笔者在近期的项目中遇到了一个与文件操作相关的问题. 在代码实现的过程中,笔者首先定义了一个文件路径:def PATH = "/a/b/c.txt&qu ...

  9. React远程服务

    http://web1.dev5.net:3002/cloud/start?server=exf2&name=zhangxiaocong http://web1.dev5.net:3002/c ...

  10. PE文件格式介绍

    Useful Tools: 1. WDK安装目录下搜下depends.exe,这个工具可以查看.exe文件依赖的.dll,以及用到的dll中的api. 2.PE文件格式分析器: 有很多的PE格式分析器 ...