题目链接:

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. ipset高大上性能果断将nf-HiPac逼下课

    netfilter.sourceforge,github上有一个凄凉的项目,那就是nf-hipac.这个以前给Linux firewall设计带来希望的项目早在2005年就停止了更新和维护,而我本人则 ...

  2. weighted Kernel k-means 加权核k均值算法理解及其实现(一)

    那就从k-means开始吧 对于机器学习的新手小白来说,k-means算法应该都会接触到吧.传统的k-means算法是一个硬聚类(因为要指定k这个参数啦)算法.这里利用百度的解释 它是数据点到原型的某 ...

  3. 解决win10客户机本地账户登陆导致远程桌面没法访问问题

    情景:客户机器如果是win10本地账户,我们远程桌面连接是可能会没法访问. 如果客户机器切换到win10 Microsoft账户登录,远程桌面就可以访问了(当然用户肯定不能给你说自己的Microsof ...

  4. 位运算总结&拾遗

    JavaScript 位运算总结&拾遗 最近补充了一些位运算的知识,深感位运算的博大精深,此文作为这个系列的总结篇,在此回顾下所学的位运算知识和应用,同时也补充下前文中没有提到的一些位运算知识 ...

  5. matlab练习程序(PCA<SVD>)

    clear all;close all;clc;img1=imread('Corner.png');img2=imread('Corner1.png');img3=imread('Corner2.pn ...

  6. char* 和char[]差异

    从因特网以下内容.笔者和总结汇总. 1. 问题介绍 问题引入: 在实习过程中发现了一个曾经一直默认的错误.相同char *c = "abc"和char c[]="abc& ...

  7. js之面向对象----封装篇

    学习了一天的面向对象总结一下,共分为三类 - -! 老规矩 第一部分是概念性知识!!! 面向对象编程,我们可以把他想象成我们在造人.一个对象便是一个人,这个人有胳膊有腿,这便是一个对象的属性或者方法. ...

  8. OWIN轻量型框架介绍

    OWIN轻量型框架介绍 阅读目录 引言 框架的特色 如何启动 各项功能 静态路由的3种写法 伪静态路由的支持 处理Form表单提交的文件 流式处理Post请求的数据 多种请求类型自动识别 响应处理 请 ...

  9. React实践(一)

    该实践取自官方教程:https://github.com/reactjs/react-tutorial 主要是自实现的过程以及一些心得体会 该实践是实现一个评论框. 一个展示所有评论的视图 一个提交评 ...

  10. Sql Server 2008R2版本中有关外键Foreign的使用

    原文:Sql Server 2008R2版本中有关外键Foreign的使用 1. 在数据库设计的过程中往往会想让2张表进行关联而使用到Foreign从而加强2张表之间的约束(如图) 以前有个问题一直没 ...