传送门: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. LaTeX工具——mathpix安利

    官网: https://mathpix.com/ 效果看下图: 图片打不开点这里 识别效果还行,感觉很适合jbc/zcy这种不喜欢打LaTex公式的神仙.

  2. crm踩坑记(一)

    目录 antd es6 Object.entries() Object.keys() Object.getOwnPropertyNames() 很神奇的用法!!! eslint 傻逼 其他 参考 an ...

  3. 在测试时用到的一些mysql的小技巧(持续更新)

    经常使用的快捷键: 1.ctrl+q 打开查询窗口 2.ctrl+/ 注释sql语句 3.ctrl+shift +/ 解除注释 4.ctrl+r 运行查询窗口的sql语句 5.ctrl+shift+r ...

  4. SQL 语句中 exists和not exists的用法

    exists       (sql       返回结果集,为真)   not       exists       (sql       不返回结果集,为真) 如下: 表A ID   NAME    ...

  5. [HNOI2004]打鼹鼠

    鼹鼠是一种很喜欢挖洞的动物,但每过一定的时间,它还是喜欢把头探出到地面上来透透气的.根据这个特点阿牛编写了一个打鼹鼠的游戏:在一个\(n*n\)的网格中,在某些时刻鼹鼠会在某一个网格探出头来透透气.你 ...

  6. python3.x 编码问题

  7. 扩展欧几里得 求ax+by == n的非负整数解个数

    求解形如ax+by == n (a,b已知)的方程的非负整数解个数时,需要用到扩展欧几里得定理,先求出最小的x的值,然后通过处理剩下的区间长度即可得到答案. 放出模板: ll gcd(ll a, ll ...

  8. MySQL统计数据库表大小

    use information_schema; SELECT TABLE_NAME, (DATA_LENGTH/1024/1024) as DataM , (INDEX_LENGTH/1024/102 ...

  9. gitbook.explore更新升级了, 不能再搜索了

    www.gitbook.com/explore 不再是一个索引页面 Can I browse existing projects on GitBook ? The new version of Git ...

  10. KMP板子+Trie板子

    KMP算法是一个字符串匹配算法,最直白的用法就是在一个长度为n的字符串T中查找另一个长度为m字符串P的匹配(总之就是用于文本中进行单个字符串的匹配). 对于这个问题,暴力算法是很好做的,直接对于T的每 ...