poj 2369(置换群)】的更多相关文章

Permutations Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3041   Accepted: 1641 Description We remind that the permutation of some final set is a one-to-one mapping of the set onto itself. Less formally, that is a way to reorder eleme…
Description We remind that the permutation of some final set is a one-to-one mapping of the set onto itself. Less formally, that is a way to reorder elements of the set. For example, one can define a permutation of the set {1,2,3,4,5} as follows:  Th…
We remind that the permutation of some final set is a one-to-one mapping of the set onto itself. Less formally, that is a way to reorder elements of the set. For example, one can define a permutation of the set {1,2,3,4,5} as follows:  This record de…
题意:给你一个变换规则,和一个字符串,问经过k次变换后得到的字符串. 思路:开始的时候试图去找它的整个周期,谁知道周期太大了,各种RE,后来在得知此题需要用置换群来优化,第一次接触置换群学习了下! 代码实现: #include<cstdio> #include<cstring> #include<iostream> #include<vector> using namespace std; ]; ]; vector<]; ]; int n,k,num;…
Cow Sorting Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 6993   Accepted: 2754 Description Farmer John's N (1 ≤ N ≤ 10,000) cows are lined up to be milked in the evening. Each cow has a unique "grumpiness" level in the range 1...…
题目大意是: 每头牛都有一个对应的值a[i],现在给定一个初始的牛的序列,希望通过两两交换,能够使这些牛按值升序排列,每次交换都会耗费一个 a[i]+a[j] 希望耗费最小,求出这个最小耗费 个人觉得这道题还是蛮有意思的,虽然我wa了很多发,但还是很值得思考一下的 这是一个置换群问题,但是我们首先要根据其值排个序确定每头牛本来应该属于的位置,再根据现在所在的位置得到一个映射关系to[i] 将a[i]又用b[]数组保存,排序后,b[i]表示第i大的牛的值 我们找出这个置换群中的所有循环集,每个循环…
题目大意: 给定了一组对应关系,经过k次幂后,得到新的对应关系b[i],然后将给定的字符串上的第i位字符放置到b[i]的位置上, 如果字符串长度不足n就用空格补足,这里的是空格,也就是str[i] = ' ',不是str[i]='\0' ,自己这里错了好几回就是找不到问题,看了别人代码才明白 置换群的k次幂问题不清楚,可以看看<<置换群快速幂运算+研究与探讨.pdf>> 这里初始给定的置换群要注意这个群不一定是一个循环集,我们要先统计出它的每一个循环集,然后每一个分别进行操作计算…
我们知道,当循环长度为L时,置换群幂次为K ,则结果是GCD(L,K)个积相乘. 于是,我们只需要求出每个循环的长度,求得它们的最小公倍数即为解. #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #define LL __int64 #define N 1000 using namespace std; int stack[N+1],top; int…
傻逼图论. #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #define maxv 1050 #define maxn 1050 #define maxe 2050 using namespace std; ,g[maxv],ans[maxn],sum=,cnt=; bool vis[maxn]; struct edge { int v,nxt; }e[ma…
题意:给定n头母牛的脾气大小,然后让你通过交换任意两头母牛的位置使得最后的母牛序列的脾气值从小到大,交换两头母牛的代价是两个脾气之和,使得代价最小. 分析:以前做过一道题,只有一个地方和这道题不同,但是实际意思确是天壤之别,这里是任意两头牛都可以交换,而以前那道题是只能交换相邻的.以前那道题是hdu 2838, 是一道求逆序数的题,树状数组解决之:当我看到这道题时,开始都没注意到这点,以为和以前做的那道题是一样的,后来才发现完全不一样!具体方法就是在数列中找置换环,每个环有两种处理方式,一种是用…
题目链接 给一个数列, 求这个数列置换成1, 2, 3....n需要多少次. 就是里面所有小的置换的长度的lcm. #include <iostream> #include <vector> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <map> #include <set> #inclu…
寻找循环节求lcm够了,如果答案是12345应该输出1.这是下一个洞. #include<iostream> #include<cstdio> #include<cstring> #include<string> #include<algorithm> #include<cmath> using namespace std; #define INF 0x3FFFFFF #define MAXN 2222 #define eps 1e-…
题意:给你一堆无序的数列p,求k,使得p^k=p 思路:利用置换的性质,先找出所有的循环,然后循环中元素的个数的lcm就是答案 代码: #include <cstdio> #include <cstring> #include <iostream> #define maxn 1234 using namespace std; int gcd(int a,int b) { ) return a; else return gcd(b,a%b); } int lcm(int…
题意 给定一个置换形式如,问经过几次置换可以变为恒等置换 思路 就是求k使得Pk = I. 我们知道一个置换可以表示为几个轮换的乘积,那么k就是所有轮换长度的最小公倍数. 把一个置换转换成轮换的方法也很简单,从一个数出发按照置换图置换,直到置换到已经置换过的数,则这些数就构成一个轮换. 代码 [cpp] #include <iostream> #include <cstdio> #include <cmath> #include <algorithm> #i…
link:http://poj.org/problem?id=2369 置换群,最简单的那种. 找所有数字循环节的最小公倍数. /* ID: zypz4571 LANG: C++ TASK: permutations.cpp */ #include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <cct…
意图写出http://www.cnblogs.com/kuangbin/archive/2012/08/28/2661066.html这个东西的完善版. 1.置换,置换的运算 poj 2369 Permutations置换群中有一个定理:设T为一置换,e为单位置换,T^k=e,那么k的最小正整数解是T的拆分的所有循环长度的最小公倍数. #include <cstdio> ; ? a : gcd(b, a % b);} int lcm(int a,int b){return a / gcd(a,…
POJ 2296 Map Labeler / ZOJ 2493 Map Labeler / HIT 2369 Map Labeler / UVAlive 2973 Map Labeler(2-sat 二分) Description Map generation is a difficult task in cartography. A vital part of such task is automatic labeling of the cities in a map; where for e…
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1004 关于置换群:https://www.cnblogs.com/nietzsche-oier/p/6883880.html https://files-cdn.cnblogs.com/files/HocRiser/Burnside.pdf 原来 burnside 引理中的“不动点”是指一种不变化的方案啊: 这道题就用 burnside 引理,但给出的 m 个置换还不是置换群,需要再加一个…
CARDS Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 1448   Accepted: 773 Description Alice and Bob have a set of N cards labelled with numbers 1 ... N (so that no two cards have the same label) and a shuffle machine. We assume that N i…
题目链接 题意 : N头牛,每个牛的坏脾气都有一个值,每个值都不相同,把这个值按照从小到大排序,如果两个值交换,那么会花掉这两个值之和的时间,让你花最少的时间将每个值从小到大排好序,求最小的总时间. 思路 : 这个在黑书上有写,就是置换群,248页有写.写的挺详细的.每个状态都可以分为若干个循环的乘积.对于任意循环 i ,设其长度为ki,则至少需要交换ki-1次,即每次让一个元素到达目标位置,而当第ki-1个元素到达目标以后显然第ki个也已经到达目标.第一个方法是让循环中最小的元素t参加所有的交…
题目链接 题意 :由n个数字组成的密钥,每个数字都不相同,都在1-n之间,有一份长度小于等于n的信息,要求将信息放到密钥下边,一一对应,信息不足n的时候补空格,然后将位置重新排列,将此过程重复k次,求最后的字符串序列,最后的空格不用输出. 思路 :如果按照最原始的求循环结的话会超时,因为k值范围很大.所以要用置换群,把每个的元素的循环求出来,直接对其取余即可.会3270的话,这个题理解起来挺容易的. #include <stdio.h> #include <string.h> #i…
[题目链接] http://poj.org/problem?id=1721 [题目大意] 给出a[i]=a[a[i]]变换s次后的序列,求原序列 [题解] 置换存在循环节,因此我们先求出循环节长度,置换后的序列经过len-s%len变换后就能得到原数列 [代码] #include <cstdio> const int N=1010; int a[N],a1[N],a0[N],n,s; void Getnxt(){ for(int i=1;i<=n;i++)a0[i]=a1[a1[i]];…
题意:给你一个置换P,问是否存在一个置换M,使M^2=P 思路:资料参考 <置换群快速幂运算研究与探讨> https://wenku.baidu.com/view/0bff6b1c6bd97f192279e9fb.html 结论一: 一个长度为 l 的循环 T,l 是 k 的倍数,则 T^k 是 k 个循环的乘积,每个循环分别是循环 T 中下标 i mod k=0,1,2- 的元素按顺序的连接. 结论二:一个长度为 l 的循环 T,gcd(l,k)=1,则 T^k 是一个循环,与循环 T 不一…
POJ 3270 Cow Sorting 题意: 一个序列变为升序,操作为交换两个元素,代价为两元素之和,求最小代价 题解: 看了黑书... 首先循环因子分解 一个循环完成的最小代价要么是循环中最小元素依次与其他交换,要么引入全局最小值来交换 $sum+min(mn*(len-2),mn+Min*(len+1))$ #include<iostream> #include<cstdio> #include<cstring> #include<algorithm>…
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1004 http://poj.org/problem?id=2409 学习材料:https://www.cnblogs.com/nietzsche-oier/p/6883880.html https://files-cdn.cnblogs.com/files/HocRiser/Burnside.pdf bzoj 1004:这道题注意考虑单位元的那个置换. 然后用 polya 定理即可.不动点…
题目链接:http://poj.org/problem?id=2409 题意: 有一串n个珠子穿起来的项链,你有k种颜色来给每一个珠子染色. 问你染色后有多少种不同的项链. 注:“不同”的概念是指无论怎样旋转或翻转项链,都与之前的不同. 题解: 本题用到了置换的相关知识: (1)Burnside引理: 等价类数目 = 所有C(f)的平均值 (C(f)为置换f的不动点数目) (2)置换f可以分解成m(f)个循环的乘积,假设涂k种颜色: C(f) = k^m(f) (3)Polya定理:(综上) 等…
题目链接 很早之前就看过这题,思路题把,确实挺难想的,黑书248页有讲解. #include <cstdio> #include <cstring> #include <iostream> #include <cmath> #include <algorithm> using namespace std; ]; struct node { int id; int x; int pos; }num[]; ],minz; int cmp1(node…
题意:给你一个数列,第i号位置的数位a[i],现在将数列进行交换,交换规则为a[i]=a[a[i]]:已知交换s次之后的序列,求原先序列 思路:置换的问题必然存在一个循环节,使一个数列交换n次回到原来的数列上,我们只需要模拟交换找到循环节长度len,将已知的交换后的序列,则再进行 (len - s%len) 次交换即可得到原序列 代码: #include <cstdio> #include <cstring> #include <iostream> #define ma…
传送门 $1A$太爽了 从此$Candy?$完全理解了这种$DP$做法 和bzoj1025类似,不过是求最大的公倍数,并输出一个字典序最小的方案 依旧枚举质因子和次数,不足的划分成1 输出方案从循环长度小的到大的输出 #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> using namespace std; ; typ…
传送门 题意:26个大写字母的置换$B$,是否存在置换$A$满足$A^2=B$ $A^2$,就是在循环中一下子走两步 容易发现,长度$n$为奇数的循环走两步还是$n$次回到原点 $n$为偶数的话是$\frac{n}{2}$次,也就是说分裂成了两个循环 综上$B$中长度为偶数的循环有奇数个就是不存在啦 #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #inclu…