传送门: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. javascript数据相关处理,序列化反序列化,数据编码与解码

    对象序列化简而言之,将对象转为字符串.在数据的传输过程中,经常会使用到对象序列化. javascript中常用的对象序列化:JSON.stringify(); javascript中常用的对象反序列化 ...

  2. 玩转Node.js(四)-搭建简单的聊天室

    玩转Node.js(四)-搭建简单的聊天室 Nodejs好久没有跟进了,最近想用它搞一个聊天室,然后便偶遇了socket.io这个东东,说是可以用它来简单的实现实时双向的基于事件的通讯机制.我便看了一 ...

  3. js中DOM 节点的一些操作方法

    什么是DOM DOM:文档对象模型.DOM 为文档提供了结构化表示,并定义了如何通过脚本来访问文档结构.目的其实就是为了能让js操作html元素而制定的一个规范. DOM就是由节点组成的. 解析过程 ...

  4. linux ----- Vim进入和退出命令

    Vim进入和退出命令     本来不想写任何关于vim的文章的,无奈我今天又忘记怎么退出vim了,常用命令是ESC,然后:wq(保存并退出),:q!(不保存并强制退出),i进入vim模式.另外还有其它 ...

  5. 怎么用Q-Q图验证数据集的分布

    样本数据集在构建机器学习模型的过程中具有重要的作用,样本数据集包括训练集.验证集.测试集,其中训练集和验证集的作用是对学习模型进行参数择优,测试集是测试该模型的泛化能力. 正负样本数据集符合独立同分布 ...

  6. 无缘无故出现npm 解析异常的的问题 解决方案

    npm cache clean --force try if false delete package.lock.json try again if false npm set registry ht ...

  7. php+Mysql 页面登录代码

    登录界面设置: <?php/** * Created by xx. * User: msi * Date: 2017/10/26 * Time: 18:12 *///session每次用之前都要 ...

  8. 文件名的查找——find

    查找文件!!! 命令格式:find [PATH] [option] [action] 一.参数1——与时间有关的参数 -atime.-ctime.-mtime -mtime n:在n天之前的“一天之内 ...

  9. 文件特殊权限:SUID,SGID,SBIT

    我们之前认识的文件的权限仅局限于r,w,x,但如果我们执行命令“ll /tmp; ll /usr/bin/passwd”,会出现除了r,w,x之外的其他字母: 即出现了特殊权限(s跟t). [SetU ...

  10. 并查集——poj1182(带权并查集高阶)

    题目链接:食物链 题解:点击 说一声:这题关系推导值得学习.