VJ 1021 Victoria的舞会1

描述

Victoria是一位颇有成就的艺术家,他因油画作品《我爱北京天安门》闻名于世界。现在,他为了报答帮助他的同行们,准备开一个舞会。

Victoria准备邀请n个已经确定的人,可是问题来了:
这n个人每一个人都有一个小花名册,名册里面写着他所愿意交流的人的名字。比如说在A的人名单里写了B,那么表示A愿意与B交流;而且如果A名单里面有B,那么B名单里面肯定有A,也就是说两个人如果一方愿意和另一方交流,那么另一方也肯定愿意和这一方交流。

Victoria觉得需要在这n个人里面确定m个人,保证这m个人每一个人都能在舞会的n个人中找到至少k个人交流,并求出一种方案以确定m的最大值是多少。

注意:自己的名单里面不会有自己的名字。

格式

输入格式

第一行两个数n和k。接下来n行,每i+1行表示编号为i的人的小花名册名单,名单以0结束。1<=n,k<=200。

输出格式

一个数,m。

样例1

样例输入1[复制]

22 1
4 5 10 11 20 21 0
2 3 6 8 11 16 0
2 3 5 8 12 15 16 18 0
1 5 6 10 11 12 16 18 0
1 3 4 16 20 0
2 4 19 21 22 0
8 9 13 19 20 0
2 3 7 10 19 0
7 10 14 16 19 0
1 4 8 9 10 20 0
1 2 4 18 19 20 21 0
3 4 13 0
7 12 15 16 18 19 21 22 0
9 16 0
3 13 21 0
2 3 4 5 9 13 14 20 0
18 22 0
3 4 11 13 17 21 0
6 7 8 9 11 13 19 21 22 0
1 5 7 10 11 16 21 22 0
1 6 11 13 15 18 19 20 0
6 13 17 19 20 0

样例输出1[复制]

22

限制

每个测试点1秒。

SB题。。

CODE:

#include <iostream>
#include <cstdio>
#include <cstring>
#define REP(i, s, n) for(int i = s; i <= n; i ++)
#define REP_(i, s, n) for(int i = n; i >= s; i --)
#define MAX_N 200 + 10

using namespace std;

int main(){
    int n, k, res = 0;
    scanf("%d%d", &n, &k);
    REP(i, 1, n){
        int tmp, num = 0;
        while(scanf("%d", &tmp) != EOF){
            if(tmp == 0) break;
            num ++;
        }
        if(num >= k) res ++;
    }
    printf("%d\n", res);
    return 0;
}
时间: 2024-08-29 05:51:00

VJ 1021 Victoria的舞会1的相关文章

COGS 1051. [Vijos1021] Victoria的舞会1

1051. [Vijos1021] Victoria的舞会1 #include<bits/stdc++.h> using namespace std; #define maxn 2333 int n,m,x,num[maxn<<3],ans; char ch; inline void read(int &now) { ch=getchar(); now=0; while(ch>'9'||ch<'0') ch=getchar(); while(ch>='0'

COGS 1052. [Vijos1022] Victoria的舞会2

1052. [Vijos1022] Victoria的舞会2 并查集吧... #include<bits/stdc++.h> using namespace std; #define maxn 1000000 #define maxm 2333 int n,m,ans,fa[maxn],x,a[maxm][maxm]; int find(int x) { return fa[x]==x?x:fa[x]=find(fa[x]); } int main() { freopen("vict

Vijos Victoria的舞会3

描述 Victoria是一位颇有成就的艺术家,他因油画作品<我爱北京天安门>闻名于世界.现在,他为了报答帮助他的同行们,准备开一个舞会. Victoria准备邀请n个已经确定的人,可是问题来了:这n个人每一个人都有一个小花名册,名册里面写着他能够通知到的人的名字.比如说在A的人名单里写了B,那么表示A能够通知到B:但是B的名单里不见的有A,也就是说B不见得通知到A. Victoria觉得需要确定自己需要通知多少个人m,能够实际将所有人n都通知到.并求出一种方案以确定m的最小值是多少. 注意:自

大神刷题表

9月27日 后缀数组:[wikioi3160]最长公共子串 dp:NOIP2001统计单词个数 后缀自动机:[spoj1812]Longest Common Substring II [wikioi3160]最长公共子串 [spoj7258]Lexicographical Substring Search 扫描线+set:[poj2932]Coneology 扫描线+set+树上删边游戏:[FJOI2013]圆形游戏 结论:[bzoj3706][FJ2014集训]反色刷 最小环:[poj1734

舞会3(同刻录光盘,并查集)

描述 Victoria是一位颇有成就的艺术家,他因油画作品<我爱北京天安门>闻名于世界.现在,他为了报答帮助他的同行们,准备开一个舞会. Victoria准备邀请n个已经确定的人,可是问题来了:这n个人每一个人都有一个小花名册,名册里面写着他能够通知到的人的名字.比如说在A的人名单里写了B,那么表示A能够通知到B:但是B的名单里不见的有A,也就是说B不见得通知到A. Victoria觉得需要确定自己需要通知多少个人m,能够实际将所有人n都通知到.并求出一种方案以确定m的最小值是多少. 注意:自

1021. Deepest Root (25) 并查集&amp;&amp;DFS

1021. Deepest Root (25) 时间限制 1500 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue A graph which is connected and acyclic can be considered a tree. The height of the tree depends on the selected root. Now you are supposed to find the root t

luogu P2863 [USACO06JAN]牛的舞会The Cow Prom

https://www.luogu.org/problem/show?pid=2863#sub 题目描述 The N (2 <= N <= 10,000) cows are so excited: it's prom night! They are dressed in their finest gowns, complete with corsages and new shoes. They know that tonight they will each try to perform th

[Sdoi2017]新生舞会

[Sdoi2017]新生舞会 http://www.lydsy.com/JudgeOnline/problem.php?id=4819 Time Limit: 10 Sec  Memory Limit: 128 MB[Submit][Status][Discuss] Description 学校组织了一次新生舞会,Cathy作为经验丰富的老学姐,负责为同学们安排舞伴.有n个男生和n个女生参加舞会 买一个男生和一个女生一起跳舞,互为舞伴.Cathy收集了这些同学之间的关系,比如两个人之前认识没计算

HDU 1021[Fibonacci Again]规律

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1021 题目大意:首两项为7,11的斐波那契数列.若第n项能被3整除,输出yes,否则输出no 关键思想:模三加法情况有限,找规律. 代码如下: #include <iostream> using namespace std; int main(){ int n; while(cin>>n) if(n%8==2||n%8==6)cout<<"yes"<