传送门: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. Promise关键知识

    异步是ES6中使用频率最高的特性之一,也是面试中经常会被问到的问题,特此整理了相应的笔记 一.Promise的三种状态 pending-异步操作没有结束 fulfilled-异步操作已成功结束,最常见 ...

  2. Python-学习-项目1-即时标记-1

    买了一本Python入门,奈何看不下去,只能是先看后面的项目,看到那里不懂的时候在回去学习. 项目名字:即时标记 大致的意思就是把一个纯文本文件标记成自己想要的格式文件. 首先就是待处理文本,我找不到 ...

  3. mysql 连接问题

    用两个表(a_table.b_table),关联字段a_table.a_id和b_table.b_id来演示一下MySQL的内连接.外连接( 左(外)连接.右(外)连接.全(外)连接). MySQL版 ...

  4. [译]如何撤销git仓库里的所有修改?

    原文来源:https://stackoverflow.com/questions/29007821/git-checkout-all-the-files 问: 如何撤销我在我git仓库所做的所有修改? ...

  5. [整理]docker内部时区修改的两种方法

    方法一 终端执行 date命令,查看宿主服务器的时区是否正确 如果正确: 执行 docker cp /etc/localtime 容器ID:/etc/localtime 将本地时间拷贝到docker内 ...

  6. python中locals和globals函数

    参考:http://www.cnblogs.com/wanxsb/archive/2013/05/07/3064783.html Python有两个内置的函数,locals() 和globals(), ...

  7. window下对samba的清理操作

    windows清除访问samba局域网密码缓存 1.在dos窗口中输入control userpasswords2或者control keymgr.dll,然后[高级]/[密码管理],删掉保存的该机器 ...

  8. 第四次JAVA作业

    public class TvbDog { public static void main(String[] args) {  Dog per=new Dog("陈狗"," ...

  9. grpc deadlines

    最近在将应用的rpc更换为grpc,使用过程中,发现报“rpc error:code=DeadlineExceeded desc = context deadline exceeded”,这是啥?原来 ...

  10. Java中WeakHashMap实现原理深究

    一.前言 我发现Java很多开源框架都使用了WeakHashMap,刚开始没怎么去注意,只知道它里面存储的值会随时间的推移慢慢减少(在 WeakHashMap 中,当某个“弱键”不再正常使用时,会被从 ...