18 Wheeler Caravans (aka Semigroups)

A binary operation on a set S is a function that assigns to each ordered pair of elements of S a unique element of S. We often use some special symbol (such as * or +) to represent a binary operation. For example, if we use the symbol '#' to represent some arbitrary binary operation on the set S = {a, b, c}, then a#b equals some element of S (as does b#a, a#a, a#c, and every other possible permutation).
From the above definition, it would follow that the normal definitions for addition, subtraction, and multiplication are all binary operations when defined on the set of all integers. However, division (the mathematical kind - not "integer division") is not a binary operation for the set of integers, since 1=2 = 0.5 which is not an integer.

The use of the word "ordered" in the definition for binary operations is important, for it allows the possibility that the element assigned to a#b may be different from the one assigned to b#a. In the case of integers, this is evident with the binary operation we know as subtraction, since 5 - 3 is not equal to 3 - 5. If in a particular case, x # y = y # x for all elements x and y in the set, we say that the binary operation is commutative. The standard addition operation on the set of integers is commutative.

For the remainder of this problem we will only concern ourselves with small sets (1 to 26 elements). For small sets such as these, the unique assignments that define an operation can be expressed by simply writing down all possible assignments in a "multiplication" table. For instance, the binary operation '#' on the set S = {a, b, c} might be defined by:

# | a b c

a | b c b
b | a c b
c | c b a

The left column of the table represents the first number in an ordered pair, and the top row represents the second. Thus, in this example, a # b = c, b # a = a, and c # c = a. Notice that the body of the table consists solely of elements from the set S, which must be true for any binary operation. Also notice that this operation is not commutative, since b # a is not equal to a # b.

A binary operation, #, on a set S is associative if (x#y)#z = x#(y#z) for all elements x, y, and z in the set X. In the example with the table above, the operation is not associative, since (a#b)#c is not equal to a#(b#c). If a binary operation, #, on a set is associative, then we say that the pair forms a semigroup. If the binary operation is commutative as well as associative, then we say that the semigroup is commutative.

Input

Write a program that will read the elements of sets together with corresponding "multiplication" tables which denote possible binary operations. Your program should then determine if the set S with the defined operation constitutes a semigroup. If the set and corresponding table do not form a semigroup, your program should report that the pair do not form a semigroup and state why. If the set and operation pair do form a semigroup, your program should check to see if the semigroup is also a commutative semigroup.

Thus, for each set and corresponding table one of the following four results is possible:

NOT A SEMIGROUP: x#y = z WHICH IS NOT AN ELEMENT OF THE SET
NOT A SEMIGROUP: (x#y)#z IS NOT EQUAL TO x#(y#z)
SEMIGROUP BUT NOT COMMUTATIVE (x#y IS NOT EQUAL TO y#x)
COMMUTATIVE SEMIGROUP

In the first three results you should substitute actual elements of the set that yield a counter-example to the definitions for a semigroup and a commutative operation. If more than one counter-example exist, choose the lexicographically first one.

The first line of the input file contains a single integer, n where (1 <= n <= 26).

The next line of the input file will contain n unique, lower case letters of the alphabet. These letters represent the elements of the set. Although each letter is unique (no duplicates), they are not necessarily arranged in alphabetical order.

The next n lines contain the body of the "multiplication" table that corresponds to the elements in the previous line. Each of these lines will contain n lower case letters. For example, the first such line corresponds to the first row of the body of the table. We will assume that the ordering of the rows and columns of the table coincide with the ordering in the line that defines the elements of the set.

After the table, the input file will contain a line with a single integer, n where (0 <= n <= 26). If n > 0 then there is another set and corresponding table contained in the next n + 1 lines that should be reported. If n = 0 then you have reached the end of the input file.

Output

The output file should contain the following for each set and table found in the input file:

1. List of the elements of S in same order as found in the input file using the following format: S = {a,b,c,d}

2. A line that starts with a space followed by the characters '#|' followed by the n elements of the set (no spaces or commas). For example: #|abcd

3. A line that begins with a space followed by the characters '-+' followed by n more dashes '-'. For example: -+----

4. List of the n rows and columns of the "multiplication" table in the same order as found in the input file. The ith line of the table should begin with a space followed by the ith element of the set followed by the '|' character followed by the n characters in the ith row of the body of the table (no spaces). For example: a|abcd

5. One blank line.

6. One line that reports what your program found to be true. This must be one of the four possible results listed above.

7. A line of 30 dashes.

8. One blank line to separate this report from subsequent reports.

Sample Input

3
abc
abc
bca
cab
3
abc
abc
bca
4
acdb
aaaa
aaca
aaab
5
abcde
aaaaa
bbabb
cccbc
ddddd
eeeee
0

Sample Output

S = {a,b,c}
#|abc
-+---
a|abc
b|bca
c|cab

S = {a,b,c}
#|abc
-+---
a|abc
b|bca

S = {a,c,d,b}
#|acdb
-+----
a|aaaa
c|aaca
b|aaab

S = {a,b,c,d,e}
#|abcde
-+-----
a|aaaaa
b|bbabb
c|cccbc
d|ddddd
e|eeeee

## NOT A SEMIGROUP: (b#a)#c IS NOT EQUAL TO b#(a#c)

0

18 Wheeler Caravans (aka Semigroups)
Gravitation-Misner Thorne Wheeler
Gravitation-Misner Thorne Wheeler Gravitation-Misner Thorne Wheeler Gravitation-Misner Thorne Wheeler
A sequence of Problems on semigroups
A sequence of Problems on semigroups

http://www.cnblogs.com/crunchyou/archive/2013/01/19/2867735.html
AKA鉴权
﻿﻿ AKA鉴权 目前IMS的鉴权的机制有“Sip Digest”、“AKA”、“CAVE-based AKA”三种。   在《中国电信IMS网络SIP协议总体技术要求》里对这三种方式的适用范围描述如下： SIP Digest 鉴权适用于无 ISIM 卡的移动和固定终端 AKA 鉴权适用于具有 ISIM 卡的移动和固定终端
AKA认证初探
近期工作中遇到了有关SIP AKA认证的相应协议规范，目前在IMS中已得到应用支持，本文主要是希望探索一下AKA认证的具体机制，以及相应算法。为简便起见，暂时先抛开IMS内部架构，从参数着手分析AKA认证。        AKA认证主要还是基于DIGEST认证方式，在此基础上加入了对称加密机制。先简单看一下AKA的流程图与信令：     如图所示，AKA认证流程与DIGEST...

For AKA Security Salon
For AKA Security SalonFor AKA Security Salon
EAP-SIM/AKA学习资料（包括EAP-SIM白皮书，EAP-SIM测试手册等）

Xcode警告、错误解决方法总结

IMS AKA鉴权及应用流程详解
IMS AKA鉴权及应用流程详解@auth doubleRabbit @date 2017-03-14目的 了解鉴权及通信类业务相关鉴权算法的概念原理 了解IMS注册流程 了解IMS鉴权流程应用 鉴权含义鉴权是指用户访问系统的权利，是提升系统安全性的一种方式，传统鉴权方法就是用户名与密码。 鉴权与授权的区别联系。逻辑上授权过程发生在鉴权之后，而实际中有时鉴权与授权对于用户来说体现为同一过程。例如
C与C++混编所遇到的问题

5G系统——5G鉴权（5G AKA）

burrow wheeler transformation
burrow wheeler transformation, algorithm in sequence matching
CGFloat和float的区别及案例分析
CGFloat和float的区别及案例分析 在32位下，CGFloat定义为float; 在64位下，CGFloat定义为double typedef float CGFloat;// 32-bit   typedef double CGFloat;// 64-bit   编程策略： 对于需要兼容64位机器的程序而言，所有使用float的地方都改为用CGFloat。 长远角度考
【通用引导架构】基于GBA的AKA认证机制

AndroidStudio之NDK常见编译错误
1、执行ndk-build 提示error: request for member 'FindClass' in something not a structure or union /Users/lvxiangan/Workspace/Android_Studio/NDK/app/src/main/jni/test.c:33:30: error: member reference base ty...

IOS开发各种疑难 二
1、 Implicit conversion of 'BOOL' (aka 'signed char') to 'id' is disallowed with ARC 解决： [NSNumber numberWithBool:value]
Gcc编译出错处理--openssl 依赖问题

EAP-AKA认证算法源程序(基于SHA-1)

bleed aka doann ajjdna
bleed aka doann ajjdna

北京的这个夏天真的很凉快，7月份下了28天雨，好多天的最高气温只有22度，以至于来自武汉的老乡Ark体会到这种凉爽，竟然忿忿不平地说："北京的夏天太假了。" 每到这个时候，我就可以摆一摆老资格，语重心长地说，北京的夏天不都这么假，也有桑那天，也有酷热难耐的时候。比如1999年40度的夏天... 一提起那个夏天，我的思想就会开小差，想起很多事情。五道口附近那个热烘烘的小旅馆，清华新大
Normal (aka Gaussian) distribution 正态分布 高斯分布算法 C#
Normal (aka Gaussian) distribution
NAS信令学习笔记 ——AKA过程
AKA过程：Authentication and Key agreement (AKA)过程，鉴权和秘钥协商过程。 eKSI：Key Set Identifier in E-UTRAN，E-UTRAN的密码组标识。 1. 鉴权四向量 KASME：UE（USIM）和网络侧（AuC）根据CK、IK以及serving network identity （SN id）生成的中间秘钥，是EPS加...
iOS 工程的警告修复

Android 引用第三方库报错（floatingactionbutton）

Aka 应用讲座 JSP
Aka 应用讲座 JSP
【二分答案&&最短路】URAL - 2034 Caravans
Problem Description 给你n个点，m条边。接下来m行每行u, v代表u 可以到达v，边权为1。最后一行输入s,f,r。代表s到f的所有最短路中。让你求r到这些最短路中最小值的最大值。(r到这些最短路的距离是最小值。但是因为有很多条最短路，所以找出到这些条最短路的最大值) 思路： 先求出s-f的最短路的值res。在求出r到各个点的最短路。这时候二分答案。从1-n查找答案。假设
Spring in Practice, 2013

linux 编译C++错误整理
1、undefined reference to `__gxx_personality_v0' 需要-l libstdc++
Ervius_Visual_Kitchen Last Version: 1.8.1 aka 10.8.1 (1.8.1)
Ervius_Visual_Kitchen Last Version: 1.8.1 aka 10.8.1 (1.8.1)
AKAEmbedded00.pdf
AKA 嵌入式开发兴趣小组杂志第0期
【网络安全】EAP协议
EAP（Extensible Authentication Protocol），可扩展认证协议，是一种普遍使用的支持多种认证 方法的认证框架协议，主要用于网络接入认证。 该协议一般运行在数据链路层上，即可以直接运行于PPP或者IEEE 802之上，不必依赖于IP。EAP 可应用于无线、有线网络中。 EAP的架构非常灵活，在Authenticator（认证方）和Supplicant（客户端）
3gpp-aka-milenage
3gpp-aka-milenage全部投文件和c文件的完整实现，具体参考