注意以下数据:
[] ++ []
[] -- [1,2]
[1,2] ++ []
[] ++ [1]
[2] ++ []
[2,3] -- []
结果是
[]
[]
[1,2]
[1]
[2]
[2,3]

 /* 3242 */
#include <cstdio>
#include <cstring>
#include <cstdlib> #define MAXN 205 typedef struct {
char s[];
bool f;
} word_t; word_t words[][MAXN];
int n[], len[];
char src[][MAXN];
char op[]; int main() {
int i, j, k; #ifndef ONLINE_JUDGE
freopen("data.in", "r", stdin);
#endif while (scanf("%s", src[])!=EOF && (src[][]!='.')) {
scanf("%s %s", op, src[]);
n[] = n[] = ;
for (i=; i<; ++i) {
k = ;
for (j=; src[i][j]; ++j) {
if (src[i][j]==',' || src[i][j]==']') {
if (src[i][j-] != '[') {
words[i][n[i]].s[k] = '\0';
words[i][n[i]].f = true;
n[i]++;
k = ;
}
} else {
words[i][n[i]].s[k++] = src[i][j];
}
}
len[i] = j;
} if (op[] == '+') {
src[][len[]-] = '\0';
printf("%s", src[]);
if (n[] == ) {
printf("]\n");
} else {
if (n[] == )
printf("%s\n", src[]+);
else
printf(",%s\n", src[]+);
}
} else {
for (j=; j<n[]; ++j) {
for (i=; i<n[]; ++i) {
if (words[][i].f && strcmp(words[][i].s, words[][j].s)==) {
words[][i].f = false;
break;
}
}
}
printf("[");
i = ;
while (i < n[]) {
if (words[][i].f)
break;
++i;
}
if (i < n[]) {
printf("%s", words[][i].s);
++i;
while (i < n[]) {
if (words[][i].f)
printf(",%s", words[][i].s);
++i;
}
}
printf("]\n");
}
} return ;
}

【HDOJ】3242 List Operations的更多相关文章

  1. 【HDOJ】4729 An Easy Problem for Elfness

    其实是求树上的路径间的数据第K大的题目.果断主席树 + LCA.初始流量是这条路径上的最小值.若a<=b,显然直接为s->t建立pipe可以使流量最优:否则,对[0, 10**4]二分得到 ...

  2. 【HDOJ】【3506】Monkey Party

    DP/四边形不等式 裸题环形石子合并…… 拆环为链即可 //HDOJ 3506 #include<cmath> #include<vector> #include<cst ...

  3. 【HDOJ】【3516】Tree Construction

    DP/四边形不等式 这题跟石子合并有点像…… dp[i][j]为将第 i 个点开始的 j 个点合并的最小代价. 易知有 dp[i][j]=min{dp[i][j] , dp[i][k-i+1]+dp[ ...

  4. 【HDOJ】【3480】Division

    DP/四边形不等式 要求将一个可重集S分成M个子集,求子集的极差的平方和最小是多少…… 首先我们先将这N个数排序,容易想到每个自己都对应着这个有序数组中的一段……而不会是互相穿插着= =因为交换一下明 ...

  5. 【HDOJ】【2829】Lawrence

    DP/四边形不等式 做过POJ 1739 邮局那道题后就很容易写出动规方程: dp[i][j]=min{dp[i-1][k]+w[k+1][j]}(表示前 j 个点分成 i 块的最小代价) $w(l, ...

  6. 【HDOJ】【3415】Max Sum of Max-K-sub-sequence

    DP/单调队列优化 呃……环形链求最大k子段和. 首先拆环为链求前缀和…… 然后单调队列吧<_<,裸题没啥好说的…… WA:为毛手写队列就会挂,必须用STL的deque?(写挂自己弱……s ...

  7. 【HDOJ】【3530】Subsequence

    DP/单调队列优化 题解:http://www.cnblogs.com/yymore/archive/2011/06/22/2087553.html 引用: 首先我们要明确几件事情 1.假设我们现在知 ...

  8. 【HDOJ】【3068】最长回文

    Manacher算法 Manacher模板题…… //HDOJ 3068 #include<cstdio> #include<cstring> #include<cstd ...

  9. 【HDOJ】【1512】Monkey King

    数据结构/可并堆 啊……换换脑子就看了看数据结构……看了一下左偏树和斜堆,鉴于左偏树不像斜堆可能退化就写了个左偏树. 左偏树介绍:http://www.cnblogs.com/crazyac/arti ...

随机推荐

  1. 'Service' object has no attribute 'process'

    在使用selenium+phantomjs时,运行总是出现错误信息: 'Service' object has no attribute 'process' 出现该错误的原因是未能找到可执行程序&qu ...

  2. 11.2 afternoon

    #include<iostream> #include<cstdio> #define ll long long using namespace std; ll n,ans; ...

  3. Java-Android 之单选按钮的运用

    <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=&quo ...

  4. vs在winform中不给力哈-错误不提示

    我的操作系统是windows Server 2008 x64,运行winform的时候,对Dictionary累加值.运行的时候,项目一闪而过,于是我在Project的Properties上选择运行的 ...

  5. Unity Manual 用户手册

    unity3d 文档的中文网址:   http://game.ceeger.com/Manual/

  6. table强制不换行

    用iframe做了一个查询,里面有一个表格,结果当页面内容多的时候挤在了一起. 上图:

  7. [Client]动检参数讨论与ONVIF

    [问题]客户端访问ONVIF设备动检 客户端要访问ONVIF设备(IPC)的动检,一是事件,二是设置: 此处就是讨论如何设置动检区域的. 通过Video Analytics/Cell Motion D ...

  8. removing right click context menu options on recycle bin

    Humpty is correct as always  First you might want to make a backup of the reg key then remove the Wa ...

  9. linux之uniq

    Linux命令uniq的作用是过滤重复部分显示文件内容,这个命令读取输入文件,并比较相邻的行.在正常情况下,第二个及以后更多个重复行将被删去,行 比较是根据所用字符集的排序序列进行的.该命令加工后的结 ...

  10. NPOI使用手册

    HSSFSheet sheet = hssfworkbook.CreateSheet("new sheet"); // Create a row and put some cell ...