题目链接  National Property 给定n个单词,字符集为m 现在我们可以把其中某些字母变成大写的.大写字母字典序大于小写字母. 问是否存在一种方案使得给定的n个单词字典序不下降. 首先判断是否存在相邻的两个单词,后一个是前一个的前缀.(两者不相等) 如果出现这种情况则直接输出无解. 建立起点s和终点t.每次扫描相邻的两个单词,找到他们第一个不相等的字母的位置. 和s相连的字母必须改成大写,和t相连的字母必须不能改成大写. 设前面那个单词的这个位置的字母为a, 后面的为b 如果a >…
在这题上不是标准的“a或b”这样的语句,因此需要进行一些转化来进行建边.同时在这题上点数较多,用lrj大白书上的做法会T,因此采用求强连通分量的方法来求解(对一个点,如果其拓扑序大于其为真的那个点,则这个语句为真,都相同则无解,否则为假).AC代码如下: #include <bits/stdc++.h> using namespace std; ; typedef long long ll; ],low[N*]; ],scc_cnt; stack<int> S; vector<…
题意:有n个有小写字母组成的字符串,将部分小写字母改成对应的大写字母,注意某种小写字母更改,所有的这种小写字母都会更改.若能使这给定的n个字符串符合字典序由小到大排序,则输出Yes,并输出需要修改的字母.定义所有的大写字母字典序小于小写字母. 分析: 1.起决定作用的是前后两个字符串中第一个不同的字母.每个字母要么小写要么大写,显然2-sat问题. 2.假设前后两个串中第一个不同的字母分别为a,b. 当a < b 时,只有a < B矛盾.则当a为小写时,b一定为小写.b为大写时,a一定为大写.…
Codeforces 828B Black Square(简单题) Description Polycarp has a checkered sheet of paper of size n × m. Polycarp painted some of cells with black, the others remained white. Inspired by Malevich's "Black Square", Polycarp wants to paint minimum pos…
1114 Family Property (25 分) This time, you are supposed to help us collect the data for family-owned property. Given each person's family members, and the estate(房产)info under his/her own name, we need to know the size of each family, and the average…
题目描述: Maximum Value time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given a sequence a consisting of n integers. Find the maximum possible value of (integer remainder of *a**i* divi…
1114 Family Property (25 分) This time, you are supposed to help us collect the data for family-owned property. Given each person's family members, and the estate(房产)info under his/her own name, we need to know the size of each family, and the average…
E. National Property time limit per test 1 second memory limit per test 512 megabytes input standard input output standard output You all know that the Library of Bookland is the largest library in the world. There are dozens of thousands of books in…
题目链接:http://codeforces.com/problemset/problem/215/B Description The World Programming Olympics Medal is a metal disk, consisting of two parts: the first part is a ring with outer radius of r1 cm, inner radius of r2 cm, (0 < r2 < r1) made of metal wi…
https://codeforces.com/problemset/problem/993/b 这题不难,暴力就能过,主要是题意太难懂了 题意: 现在有两个人,每个人手中有一对数,第一个人手中的数是n组数中的一对,第二个人手中的数是m组数中的一对 如果这两组数中只有一个数字相等,这该数为共享数字,怎样输出看思路吧 思路: 其实就是n对和m对数中,找共享数字,直接看样例吧: 在第一示例中,第一参与者通信对(1,2)和(3,4),第二参与者通信对(1,5),(3,4).因为我们知道,他们收到的实际对…