IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 开发测试 -> B. Princesses and Princes -> 正文阅读

[开发测试]B. Princesses and Princes

B. Princesses and Princes

B.公主和王子

time limit per test: 2 seconds
每次测试的时间限制:2秒

memory limit per test: 256 megabytes
每次测试的内存限制:256兆字节

input. standard input
投入。标准输入

output: standard output
产出:标准产出

The King of Berland Polycarp LXXXIV has n daughters. To establish his power to the neighbouring kingdoms he wants to marry his
伯兰·波利卡什国王LXXXIV有n个女儿。为了在邻国建立他的权力,他想和他的王国结婚

daughters to the princes of these kingdoms. As a lucky coincidence there are n other kingdoms as well.
这些王国的王子的女儿们。幸运的是,还有其他王国。

So Polycarp LXXXIV has enumerated his daughters from 1 to n and the kingdoms from 1 to n. For each daughter he has compiled a list of
因此,波利卡姆LXXXIV列举了他从1到n的女儿和从1到n的王国。他为每一个女儿编制了一份清单。

kingdoms princes of which she wanted to marry.
她想娶的王国的王子。

Polycarp LXXXIV is very busy, so he finds a couple for his daughters greedily one after another.
波利卡LXXXIV非常忙,所以他为他的女儿们找到了一对又一个贪婪的夫妇。

For the first daughter he takes the kingdom with the lowest number from her list and marries the daughter to their prince. For the
对于第一个女儿,他从她的名单上取下了数量最少的王国,并将女儿嫁给了他们的王子。为

second daughter he takes the kingdom with the lowest number from her list, prince of which hasn’t been taken already. If there are
他的第二个女儿从她的名单中得到了数字最低的王国,而她的王子还没有被带走。如果有

no free princes in the list then the daughter maries nobody and Polycarp LXXXIV proceeds to the next daughter. The process ends after
名单上没有自由的王子,那么女儿就没有人结婚,波里卡斯LXXXIV继续给下一个女儿。过程结束后

the n-th daughter.
第二个女儿。

For example, let there be 4 daughters and kingdoms, the lists daughters have are [2, 3]. [1, 2]. [3, 4]. [3], respectively.
例如,如果有4个女儿和王国,女儿的名单是[2,3]。[1,2]。[3,4]。[3]分别。

In that case daughter 1 marries the prince of kingdom 2, daughter 2 marries the prince of kingdom 1, daughter 3 marries the prince of
在这种情况下,女儿1与王国的王子结婚2,女儿2与王国的王子结婚,女儿3与国王的王子结婚。

kingdom 3, leaving daughter 4 nobody to marry to.
kingdom 3, leaving daughter 4 nobody to marry to.

    • Cont
      -+Cont

Actually, before starting the marriage process Polycarp L XXXIV has the time to convince one of his daughters that some prince is also
Actually, before starting the marriage process Polycarp L XXXIV has the time to convince one of his daughters that some prince is also

worth marrying to. Effectively, that means that he can add exactly one kingdom to exactly one of his daughter’s list. Note that this
值得嫁给。实际上,这意味着他可以在他女儿的名单中添加一个王国。注意这个

kingdom should not be present in the daughter’s list.
王国不应出现在女儿的名单上。

● Tuto
图托

Polycarp LXXXIV wants to increase the number of married couples.
PolycaroLXXXIV希望增加已婚夫妇的数量。

Unfortunately, what he doesn’t have the time for is determining what entry to add. If there is no way to increase the total number of married
不幸的是,他没有时间决定添加什么条目。如果没有办法增加结婚总数

couples then output that the marriages are already optimal. Otherwise, find such an entry that the total number of maried couples
然后,夫妇们得出的结论是,婚姻已经是最理想的了。否则,请找到这样一个条目,即已婚夫妇的总数。

increases if Polycarp LXXXIV adds it.
如果PolycaroLXXXIV添加它,则会增加。

If there are multiple ways to add an entry S0 that the total number of married couples increases then print any of them.
如果有多种方法添加已婚夫妇总数增加的条目S0,则打印其中任何一项。

For your and our convenience you are asked to answer t independent test cases.
为了您和我们的方便,我们要求您回答独立的测试用例。

Input
输入

The first line contains a single integert(1≤t < 10*)- the number of test cases.
第一行包含一个整数(1≤t<10*)–测试用例的数量。

Then t test cases follow.
然后是测试用例。

The first line of each test case contains a single integern(1 ≤n < 105)- the number of daughters and the number of kingdoms.
每个测试用例的第一行包含一个整数(1≤n<105)–女儿数和王国数。

Each of the next n lines contains the description of each daughter’s list. The first integerk(0≤k≤n) is the number of entries in the i-th
下面n行中的每一行都包含对每个女儿列表的描述。第一个整数(0≤k≤n)是i-th中的条目数。

daughter’s list. After that k distinct integers fllo 9;[1], gl[]…[9(1 < g;[j] ≤n)- the indices of the kingdoms in the list in the
daughter’s list. After that k distinct integers fllo 9;[1], gl[]…[9(1 < g;[j] ≤n)- the indices of the kingdoms in the list in the

increasing order(9;[1] < 9;[2]< … < 9;[R)-
递增顺序(9;[1]<9;[2]<.<9;[R]-

It’s guaranteed that the total number of daughters over all test cases does not exceed 10
保证所有测试用例的女儿总数不超过10个

It’s also guaranteed that the total number of kingdoms in lists over all test cases does not exceed 105.
它还保证所有测试用例列表中的王国总数不超过105个。

模拟

int t, n, k, x;
int a[100007], done[100007];

int main(){
    cin>>t;
    while(t--){
        cin>>n;
        for(int i=1; i<=n; ++i)
            a[i] = done[i] = 0;

            for(int i=1; i<=n; ++i){
               cin>>k;
                for(int j=1; j<=k; ++j){
                    cin>>x;
                    if(!a[i] && !done[x])
                        a[i] = done[x] = 1;
                }
            }
            int f = 0, i, j;
            for(i=1; i<=n; ++i){
                if(!a[i])
                    for(j=1; j<=n; ++j)
                        if(!done[j])
                        {
                            f = 1;
                            break;
                        }
                if(f)break;
            }
            if(f)	printf("IMPROVE\n%d %d\n", i, j);
            else		printf("OPTIMAL\n");
    }
    return 0;
}
  开发测试 最新文章
pytest系列——allure之生成测试报告(Wind
某大厂软件测试岗一面笔试题+二面问答题面试
iperf 学习笔记
关于Python中使用selenium八大定位方法
【软件测试】为什么提升不了?8年测试总结再
软件测试复习
PHP笔记-Smarty模板引擎的使用
C++Test使用入门
【Java】单元测试
Net core 3.x 获取客户端地址
上一篇文章      下一篇文章      查看所有文章
加:2021-08-23 16:59:40  更:2021-08-23 17:00:57 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年5日历 -2024/5/14 14:50:21-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码