题目链接:

PKU:http://poj.org/problem?id=3654

ZJU:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2936

HDU:http://acm.hdu.edu.cn/showproblem.php?pid=2723

Description

The Tyrell corporation uses a state-of-the-art electronic document system that controls all aspects of document creation, viewing, editing, and distribution. Document security is handled via access control lists(ACLs). An ACL defines a set of
entities that have access to the document, and for each entity defines the set of rights that it has. Entities are denoted by uppercase letters; an entity might be a single individual or an entire division. Rights are denoted by lowercase letters; examples
of rights are a for appendd for deletee for edit, and r for read.

The ACL for a document is stored along with that document, but there is also a separate ACL log stored on a separate log server. All documents start with an empty ACL, which grants no rights to anyone. Every time the ACL for a document is changed,
a new entry is written to the log. An entry is of the form ExR, where E is a nonempty set of entities, R is a nonempty set of rights, and x is either "+", "–", or "=". Entry E+R says to grant all the rights
in R to all the entities in E, entry ER says to remove all the rights in R from all the entities in E, and entry E=R says that all the entities in E have exactly the rights in R and
no others. An entry might be redundant in the sense that it grants an entity a right it already has and/or denies an entity a right that it doesn't have. A log is simply a list of entries separated by commas, ordered chronologically from oldest to most recent.
Entries are cumulative, with newer entries taking precedence over older entries if there is a conflict.

Periodically the Tyrell corporation will run a security check by using the logs to compute the current ACL for each document and then comparing it with the ACL actually stored with the document. A mismatch indicates a security breach. Your job is to write
a program that, given an ACL log, computes the current ACL.

Input

The input consists of one or more ACL logs, each 3–79 characters long and on a line by itself, followed by a line containing only "#" that signals the end of the input. Logs will be in the format defined above and will not contain any whitespace.

Output

For each log, output a single line containing the log number (logs are numbered sequentially starting with one), then a colon, then the current ACL in the format shown below. Note that (1) spaces do not appear in the output; (2) entities are listed in alphabetical
order; (3) the rights for an entity are listed in alphabetical order; (4) entities with no current rights are not listed (even if they appeared in a log entry), so it's possible that an ACL will be empty; and (5) if two or more consecutive entities have exactly
the same rights, those rights are only output once, after the list of entities.

Sample Input

MC-p,SC+c
YB=rde,B-dq,AYM+e
GQ+tju,GH-ju,AQ-z,Q=t,QG-t
JBL=fwa,H+wf,LD-fz,BJ-a,P=aw
#

Sample Output

1:CSc
2:AeBerMeYder
3:
4:BHJfwLPaw

Source

题意:

运算符(“‘+’, ‘-’, ''=”)前面是名字,‘+’表示把后面的权力赋给前面的人,‘-’表示从前面的人中减去后面的权力(当然没有就不减),‘=’表示把前面的人的权力先清空在把后面的权力赋给前面的人!输出的时候有同样权力的相邻两个人就名字一起输出,再一起输出权力!假设都没有权力则不输出!

代码例如以下:

#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
using namespace std;
const int maxn = 57;
int a[maxn][maxn]; int main()
{
string tt;
char str[1017];
int cas = 0;
int num[maxn];
while(scanf("%s",str)!=EOF)
{
int len = strlen(str);
if(len == 1 && str[0] == '#')
break;
tt = "";
memset(a,0,sizeof a);
for(int i = 0; i < len; i++)
{
if(str[i]==',')
tt = "";//清空
else if(str[i] == '+')
{
for(int j = i+1; str[j]!=',' && j < len; j++)
{
for(int k = 0; k < tt.size(); k++)
{
a[tt[k]-'A'][str[j]-'a']=1;
}
}
}
else if(str[i] == '-')
{
for(int j = i+1; str[j]!=',' && j < len; j++)
{
for(int k = 0; k < tt.size(); k++)
{
a[tt[k]-'A'][str[j]-'a']=0;
}
}
}
else if(str[i] == '=')
{
for(int k = 0; k < tt.size(); k++)
{
memset(a[tt[k]-'A'],0,sizeof a[0]);
for(int j = i+1; str[j]!=',' && j < len; j++)
{
a[tt[k]-'A'][str[j]-'a']=1;
}
}
}
else
tt+=str[i];
}
printf("%d:",++cas);
int l = 0;
for(int i = 0; i < 26; i++)//记录下全部有权力的人
{
int flag = 0;
for(int j = 0; j < 26; j++)
{
if(a[i][j])
flag = 1;
}
if(flag)
{
num[l++] = i;
}
} tt = "";
for(int i = 0; i < l; i++)
{
int flag = 0;
if(i != l-1)
{
for(int j = 0; j < 26; j++)
{
if(a[num[i]][j] != a[num[i+1]][j])//所含的权力不同
{
flag = 1;
}
}
}
char tem = 'A'+num[i];
tt += tem;
if(flag==1 || i==l-1)
{
cout<<tt;
tt = "";
for(int j = 0; j < 26; j++)
{
if(a[num[i]][j])
printf("%c",'a'+j);
}
}
}
printf("\n");
}
return 0;
}

POJ 3654 &amp; ZOJ 2936 &amp; HDU 2723 Electronic Document Security(模拟)的更多相关文章

  1. POJ 2240 Arbitrage / ZOJ 1092 Arbitrage / HDU 1217 Arbitrage / SPOJ Arbitrage(图论,环)

    POJ 2240 Arbitrage / ZOJ 1092 Arbitrage / HDU 1217 Arbitrage / SPOJ Arbitrage(图论,环) Description Arbi ...

  2. POJ 3100 &amp; ZOJ 2818 &amp; HDU 2740 Root of the Problem(数学)

    题目链接: POJ:id=3100" style="font-size:18px">http://poj.org/problem? id=3100 ZOJ:http ...

  3. POJ 3652 &amp; ZOJ 2934 &amp; HDU 2721 Persistent Bits(数学 元)

    主题链接: PKU:http://poj.org/problem?id=3652 ZJU:http://acm.zju.edu.cn/onlinejudge/showProblem.do? probl ...

  4. POJ 3653 &amp; ZOJ 2935 &amp; HDU 2722 Here We Go(relians) Again(最短路dijstra)

    题目链接: PKU:http://poj.org/problem? id=3653 ZJU:problemId=1934" target="_blank">http ...

  5. POJ 1325、ZOJ 1364、HDU 1150 Machine Schedule - from lanshui_Yang

    Problem Description As we all know, machine scheduling is a very classical problem in computer scien ...

  6. POJ 1087 A Plug for UNIX / HDU 1526 A Plug for UNIX / ZOJ 1157 A Plug for UNIX / UVA 753 A Plug for UNIX / UVAlive 5418 A Plug for UNIX / SCU 1671 A Plug for UNIX (网络流)

    POJ 1087 A Plug for UNIX / HDU 1526 A Plug for UNIX / ZOJ 1157 A Plug for UNIX / UVA 753 A Plug for ...

  7. HDU 4041 Eliminate Witches! (模拟题 ACM ICPC 2011亚洲北京赛区网络赛)

    HDU 4041 Eliminate Witches! (模拟题 ACM ICPC 2011 亚洲北京赛区网络赛题目) Eliminate Witches! Time Limit: 2000/1000 ...

  8. POJ 1274 The Perfect Stall、HDU 2063 过山车(最大流做二分匹配)

    The Perfect Stall Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 24081   Accepted: 106 ...

  9. POJ 2418 ,ZOJ 1899 Hardwood Species - from lanshui_Yang

    Description Hardwoods are the botanical group of trees that have broad leaves, produce a fruit or nu ...

随机推荐

  1. Hsql中In没有1000的限制

    SELECT * FROM user , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ...

  2. Nginx模块开发入门(转)

    前言 Nginx是当前最流行的HTTP Server之一,根据W3Techs的统计,目前世界排名(根据Alexa)前100万的网站中,Nginx的占有率为6.8%.与Apache相比,Nginx在高并 ...

  3. Spring 5 (0) - Introduction & Index

    Spring Framework Reference Documentation I. Overview of Spring Framework . Getting Started with Spri ...

  4. avalon组件

    如何做一个avalon组件 在avalon1.5中改用更直观的自定义标签来声明组件,废掉ms-widget,引入更强大的生命周期管理,可以让组件任意套嵌. 组件是由JS,HTML,CSS构成 JS 以 ...

  5. SQLServer表变量对IO及内存影响测试

    原文:SQLServer表变量对IO及内存影响测试 1. 测试创建表变量对IO的影响 测试创建表变量前后,tempdb的空间大小,目前使用sp_spaceused得到大小,也可以使用视图sys.dm_ ...

  6. (大数据工程师学习路径)第一步 Linux 基础入门----Linux 下软件安装

    介绍 介绍 Ubuntu 下软件安装的几种方式,及 apt,dpkg 工具的使用. 一.Linux 上的软件安装 通常 Linux 上的软件安装主要有三种方式: 在线安装 从磁盘安装deb软件包 从二 ...

  7. Angular绑定数据时转义html标签

    AngularJs在绑定数据时默认会以文本的形式出现在页面上,比如我现在有这样一段代码 <div ng-controller="testCtrl">{{data}}&l ...

  8. 无法打开物理文件mdf,操作系统错误 5:&quot;5(拒绝訪问。)&quot;

    无法打开物理文件mdf,操作系统错误 5:"5(拒绝訪问.)" 环境: SQL Server 2008 R2 问题: 附加数据库时报错"无法打开物理文件mdf.操作系统错 ...

  9. ACM核武器

    工欲善其事必先利其器,给大家介绍一下ACM里面经常使用的一些工具,平台,作为第一发福利. 详细看这里,我直接粘贴过来有些代码没贴过来  http://wuyiqi.net/house/acm_weap ...

  10. 通过HttpClient来调用Web Api接口,实体参数的传递

    下面定义一个复杂类型对象 public class User_Info { public int Id { get; set; } public string Name { get; set; } p ...