<题目链接> 题目大意: 给你一些只由小写字母组成的字符串,现在按一定顺序给出这些字符串,问你怎样从重排字典序,使得这些字符串按字典序排序后的顺序如题目所给的顺序相同. 解题分析:本题想到拓扑排序就好做了.就是枚举每个字符串,每个字符串和它前一个字符串寻找第一个不同的字符,然后前一个串的该字符向当前串的字符连一条有向边(注意判断后一个串是前一个串的子串的情况).然后就是跑一遍拓扑排序,如果不冲突的话,就可构造出答案. #include <bits/stdc++.h> using n…
Fox And Names time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Fox Ciel is going to publish a paper on FOCS (Foxes Operated Computer Systems, pronounce: "Fox"). She heard a rumor: the…
Fox And Names time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Fox Ciel is going to publish a paper on FOCS (Foxes Operated Computer Systems, pronounce: "Fox"). She heard a rumor: the…
题目链接:http://codeforces.com/contest/510/problem/C 题目大意:构造一个字母表,使得按照你的字母表能够满足输入的是按照字典序排下来. 递归建图:竖着切下来,将每个名字的第x个字母从上到下连接建图.然后求拓扑排序. 之所以要拓扑排序,因为要判断在x-1里面有a-->b  在x中有b-->a,这样就形成了一个环.这样一来,就不能够构造字母表了. [经验教训]:在递归建图的函数中开了两个数组,用来记录字母第一次出现和最后一次出现的位置..结果就RE在12上…
题目链接:http://codeforces.com/problemset/problem/510/C Fox Ciel is going to publish a paper on FOCS (Foxes Operated Computer Systems, pronounce: "Fox"). She heard a rumor: the authors list on the paper is always sorted in the lexicographical order.…
省委代码: #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<iostream> #include<algorithm> #define maxn 100 #define maxm 10000 using namespace std; struct edge{ int next,to; }e[maxm]; int point[ma…
题目传送门 /* 给出n个字符串,求是否有一个“字典序”使得n个字符串是从小到大排序 拓扑排序 详细解释:http://www.2cto.com/kf/201502/374966.html */ #include <cstdio> #include <iostream> #include <cstring> #include <string> #include <map> #include <algorithm> #include &…
原题:http://codeforces.com/problemset/problem/510/C C. Fox And Names time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Fox Ciel is going to publish a paper on FOCS (Foxes Operated Computer Sys…
[题目链接]:http://codeforces.com/contest/510/problem/C [题意] 给你n个字符串; 问你要怎么修改字典序; (即原本是a,b,c..z现在你可以修改每个字母在字典序中的位置了); 才能使得这n个字符串是字典序升序的; [题解] 对于第i个字符串; 让他和第i+1..n个字符串比较->j; 找到第一个不同的位置pos; 然后 必然是要 s[i][pos]< s[j][pos]的: 拓扑排序! 即s[i][pos]建一条边指向s[j][pos] 然后做…
C. Fox And Names time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Fox Ciel is going to publish a paper on FOCS (Foxes Operated Computer Systems, pronounce: "Fox"). She heard a rumor: t…