其实就是一个指定字符串的交换位置...还挺恶心的..写了很长不容易就贴一下吧...

各种拆分字符串,合并字符串...还有处理大小写...应该没什么trick

/********************* Template ************************/
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
#define EPS             1e-8
#define DINF            1e15
#define MAXN            100050
#define MOD             1000000007
#define INF             0x7fffffff
#define LINF            1LL<<60
#define PI              3.14159265358979323846
#define lson            l,m,rt<<1
#define rson            m+1,r,rt<<1|1
#define BUG             cout<<" BUG! "<<endl;
#define LINE            cout<<" ------------------ "<<endl;
#define FIN             freopen("in.txt","r",stdin);
#define FOUT            freopen("out.txt","w",stdout);
#define mem(a,b)        memset(a,b,sizeof(a))
#define FOR(i,a,b)      for(int i = a ; i < b ; i++)
#define read(a)         scanf("%d",&a)
#define read2(a,b)      scanf("%d%d",&a,&b)
#define read3(a,b,c)    scanf("%d%d%d",&a,&b,&c)
#define write(a)        printf("%d\n",a)
#define write2(a,b)     printf("%d %d\n",a,b)
#define write3(a,b,c)   printf("%d %d %d\n",a,b,c)
#pragma comment         (linker,"/STACK:102400000,102400000")
template<class T> inline T L(T a)               {return (a << 1);}
template<class T> inline T R(T a)               {return (a << 1 | 1);}
template<class T> inline T lowbit(T a)          {return (a & -a);}
template<class T> inline T Mid(T a,T b)         {return ((a + b) >> 1);}
template<class T> inline T gcd(T a,T b)         {return b ? gcd(b,a%b) : a;}
template<class T> inline T lcm(T a,T b)         {return a / gcd(a,b) * b;}
template<class T> inline T ABS(T a)             {return a > 0 ? a : -a;}
template<class T> inline T Min(T a,T b)         {return a < b ? a : b;}
template<class T> inline T Max(T a,T b)         {return a > b ? a : b;}
template<class T> inline T Min(T a,T b,T c)     {return min(min(a,b),c);}
template<class T> inline T Max(T a,T b,T c)     {return max(max(a,b),c);}
template<class T> inline T Min(T a,T b,T c,T d) {return min(min(a,b),min(c,d));}
template<class T> inline T Max(T a,T b,T c,T d) {return max(max(a,b),max(c,d));}
template<class T> inline T exGCD(T a, T b, T &x, T &y){if(!b) return x = 1,y = 0,a;T res = exGCD(b,a%b,x,y),tmp = x;x = y,y = tmp - (a / b) * y;return res;
}
template<class T> inline T reverse_bits(T x){x = (x >> 1 & 0x55555555) | ((x << 1) & 0xaaaaaaaa); x = ((x >> 2) & 0x33333333) | ((x << 2) & 0xcccccccc);x = (x >> 4 & 0x0f0f0f0f) | ((x << 4) & 0xf0f0f0f0); x = ((x >> 8) & 0x00ff00ff) | ((x << 8) & 0xff00ff00);x = (x >>16 & 0x0000ffff) | ((x <<16) & 0xffff0000); return x;
}
//typedef long long LL;    typedef unsigned long long ULL;
//typedef __int64 LL;      typedef unsigned __int64 ULL;
/*********************   By  F   *********************/
string str;
string obj[105],sub[105],verb[105];
int cnt1 = 0 ,cnt2 = 0 ,cnt3 = 0 ;
int len;
void divide(){for(int i = 0 ; i < len ; i++){if(str[i] == '('){for(int j = i+1 ; j < len ; j++){if(str[j] == ')'){sub[cnt1++] = str.substr(i+1,j-i-1);break;}}}}for(int i = 0 ; i < len ; i++){if(str[i] == '['){for(int j = i+1 ; j < len ; j++){if(str[j] == ']'){verb[cnt2++] = str.substr(i+1,j-i-1);break;}}}}for(int i = 0 ; i < len ; i++){if(str[i] == '{'){for(int j = i+1 ; j < len ; j++){if(str[j] == '}'){obj[cnt3++] = str.substr(i+1,j-i-1);break;}}}}
}
int main(){//FIN;while(getline(cin,str)){len = str.size();cnt1 = 0 ,cnt2 = 0 ,cnt3 = 0;for(int i = 0 ; i < len ; i++){if(str[i] >= 'A' && str[i] <= 'Z') {str[i] = str[i] - 'A' + 'a';break;}}string ssub[105];int cnt = 0;for(int i = 0 ; i < len ; i++){//cout<<i<<endl;if(str[i] == '(' || str[i] == '{' || str[i] == '['){for(int j = i+1 ; j < len ; j++){if(str[j] == ')' || str[j] == ']' || str[j] == '}'){ssub[cnt++] = str.substr(i,j-i+1);//cout<<sub[cnt-1]<<endl;i = j;break;}}}else{for(int j = i+1 ; j < len ; j++){if(str[j] == '(' || str[j] == '{' || str[j] == '['){ssub[cnt++] = str.substr(i,j-i);//cout<<sub[cnt-1]<<endl;i = j-1;break;}}}}divide();int flag = 0,c = 0;string res;for(int i = 0 ; i < cnt ; i++){if(ssub[i][0] == '(' || ssub[i][0] == '{' || ssub[i][0] == '[' ){if(flag == 0) res+=obj[c];else if(flag == 1) res+=sub[c];else if(flag == 2) res+=verb[c];if(++flag == 3){flag = 0;c++;}}else res+=ssub[i];}if(res[0] >= 'a' && res[0] <= 'z')res[0] = res[0] - 'a' + 'A';cout<<res<<endl;}return 0;
}

转载于:https://www.cnblogs.com/Felix-F/p/3400057.html

URAL 1993 This cheeseburger you don't need相关推荐

  1. URAL 1993 This cheeseburger you don't need 模拟题

    This cheeseburger you don't need 题目连接: http://acm.timus.ru/problem.aspx?space=1&num=1993 Descrip ...

  2. Ural 1018 (树形DP+背包+优化)

    题目链接: http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=17662 题目大意:树枝上间连接着一坨坨苹果(不要在意'坨'),给 ...

  3. ZZNU 1993: cots' friends

    题目描述 cot 最近非常喜欢数字, 喜欢到了什么程度呢, 已经走火入魔了.... cot把每个朋友编上一个序号,然后遇到谁就叫"XX号",对此,他的朋友们一致认为cot" ...

  4. bzoj1814 Ural 1519 Formula 1(插头dp模板题)

    1814: Ural 1519 Formula 1 Time Limit: 1 Sec  Memory Limit: 64 MB Submit: 924  Solved: 351 [Submit][S ...

  5. URAL 1635 Mnemonics and Palindromes

    URAL 1635 思路:区间dp+贪心,先n^2处理出每段区间是否是回文串,然后贪心地找每一段1到i的最少分割. 代码: #include<bits/stdc++.h> using na ...

  6. [代码]ural 1655 Somali Pirates

    Abstract ural 1655 Somali Pirates dp Source http://acm.timus.ru/problem.aspx?space=1&num=1655 So ...

  7. ural 1306. Sequence Median(优先级队列 priority_queue用法)

    最近做的ural的题目总是各种错,看了解题报告都是自己没学过的玩意,有点受打击,不过ural的题目质量还是挺好的,多被虐虐有益健康. 这一题要是用数组直接超内存,用优先级队列做,刚接触这个,学习一下优 ...

  8. DFS水题 URAL 1152 False Mirrors

    题目传送门 1 /* 2 题意:一个圈,每个点有怪兽,每一次射击能消灭它左右和自己,剩余的每只怪兽攻击 3 搜索水题:sum记录剩余的攻击总和,tot记录承受的伤害,当伤害超过ans时,结束,算是剪枝 ...

  9. 【BZOJ1814】Ural 1519 Formula 1 插头DP

    [BZOJ1814]Ural 1519 Formula 1 题意:一个 m * n 的棋盘,有的格子存在障碍,求经过所有非障碍格子的哈密顿回路个数.(n,m<=12) 题解:插头DP板子题,刷板 ...

最新文章

  1. 安卓开发|自定义监听器的三个步骤
  2. thinking-in-java(10)内部类
  3. java tostring格式化日期_java日期格式化SimpleDateFormat的使用详解
  4. Web前端——JavaScript(基本语法)
  5. oracle Rac的心跳线不支持交叉线?
  6. modbus测试plc软件,MODBUS RTU设备测试调试工具官方版
  7. Android手机音量变大器,音量扩大器:安卓大音量设置技巧
  8. lmdb数据库的读取与转换(二) —— 数据集操作
  9. 二维六点对称格式matlab,热传导方程求解的程序
  10. win7 旗舰版激活工具(附件下载)
  11. 使用eclipse编写第一个Java程序及运行(超详细)
  12. Hadoop高可用安装
  13. java other_在Java中,方法成为public / private / other是什么意思?
  14. 简单易学的win10安装教程,值得收藏
  15. 高等数学笔记-乐经良老师-第八章-多元函数微分学(Ⅰ)
  16. mysql候选关键字_MySQL——(SQL语句)
  17. uni-app 使用 Uview2.x 搭建自定义tabbar组件
  18. python文本编辑器下载_python文本编辑器下载-TextPad下载v 8.2.0最新免费版-西西软件下载...
  19. Esp32Cam WebServer 网页源代码查看与编辑
  20. 封神台 第二章 绕过WAF

热门文章

  1. 网站优化还是需要从实际工作经验中总结优化技巧
  2. 网站单页面排名提升的技巧有哪些?
  3. php序列化数据无法反解析,PHP-反序列化数据不起作用
  4. shutdown thread.java_ShutdownHook- Java 优雅停机解决方案
  5. 搭建网络及服务器系统,网络服务器搭建与管理
  6. macOS 的头文件隐藏这么深
  7. elasticsearch负载均衡节点——客户端节点 node.master: false node.data: false 其他配置和master 数据节点一样...
  8. spark RDD底层原理
  9. webstom新增vue模板
  10. [patl2-018]多项式A除以B