CF B. Gardener and the Array
B. Gardener and the Array
思路:只要找到一个c他的每一位均在除了它的集合中出现过即可
这题T了2发,用来multiset,注意multiset大的时间复杂度是O(K + logn)k是相同元素的个数,能用map尽量用map
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
void solve()
{
int n; scanf("%d", &n);
vector<int>a[n + 1];
map<int, int>cnt;
for(int i = 1; i <= n; ++ i)
{
int k;
scanf("%d", &k);
a[i].push_back(k);
for(int j = 0; j < k; ++ j)
{
int x; scanf("%d", &x);
a[i].push_back(x);
cnt[x] ++;
}
}
for(int i = 1; i <= n; ++ i)
{
int k = a[i][0];
for(int j = 1; j <= k; ++ j)
{
if(cnt[a[i][j]] < 2) break;
if(j == k && cnt[a[i][j]] >= 2)
{
printf("Yes\n");
return;
}
}
}
printf("No\n");
}
int main()
{
// freopen("1.in", "r", stdin);
int t; scanf("%d", &t);
while(t --) solve();
return 0;
}
CF B. Gardener and the Array的更多相关文章
- 暑假集训单切赛第一场 CF 266E More Queries to Array(线段树+二项式展开式)
比赛时,第二题就是做的这个,当时果断没仔细考虑,直接用线段树暴力求.结果易想而知,超时了. 比赛后搜了搜题解,恍然大悟. 思路:显然用线段树,但是由于每次查询都会有变,所以不可能存储题目中的式子. ...
- CF #535 (Div. 3) E2 Array and Segments (Hard version) 利用线段树进行区间转移
传送门 题意: 有m个区间,n个a[ i ] , 选择若干个区间,使得整个数组中的最大值和最小值的差值最小.n<=1e5,m<=300; 思路: 可以知道每个i,如果一个区间包含这个 ...
- Sona && Little Elephant and Array && Little Elephant and Array && D-query && Powerful array && Fast Queries (莫队)
vjudge上莫队专题 真的是要吐槽自己(自己的莫队手残写了2个bug) s=sqrt(n) 是元素的个数而不是询问的个数(之所以是sqrt(n)使得左端点每个块左端点的范围嘴都是sqrt(n)) 在 ...
- BeanFactory和ApplicationContext的区别+部分Spring的使用
BeanFactory和ApplicationContext的区别 ApplicationContext 方式加载:创建容器的同时 容器初始化,容器所有的bean创建完毕 Spring容器中获取一 ...
- CF 439C Devu and Partitioning of the Array
题目链接: 传送门 Devu and Partitioning of the Array time limit per test:1 second memory limit per test: ...
- B. Yet Another Array Partitioning Task ——cf
B. Yet Another Array Partitioning Task time limit per test 2 seconds memory limit per test 256 megab ...
- C. Ayoub and Lost Array cf dp
C. Ayoub and Lost Array time limit per test 1 second memory limit per test 256 megabytes input stand ...
- CF 1023D Array Restoration - 线段树
题解 非常容易想到的线段树, 还可以用并查集来. 还有一位大神用了$O(n)$ 就过了Orz 要判断是否能染色出输入给出的序列,必须满足两个条件: 1. 序列中必须存在一个$q$ 2. 两个相同的数$ ...
- CF 1008C Reorder the Array
You are given an array of integers. Vasya can permute (change order) its integers. He wants to do it ...
- CF#538(div2) B. Yet Another Array Partitioning Task 【YY】
任意门:http://codeforces.com/contest/1114/problem/B B. Yet Another Array Partitioning Task time limit p ...
随机推荐
- Nginx使用Lua脚本连接Redis验证身份并下载文件
目录 安装Nginx 下载 解压安装包 安装依赖 安装 启动 测试访问 安装LuaJIT 安装ngx_devel_kit 安装lua-nginx-module 在已安装的Nginx中添加Lua模块 L ...
- Day02_Java_作业
A:选择题 1. 若有定义:int a,b; a=a+10;则执行上述语句后,a的值是(d). A. 10 B. 11 C. 0 D. 编译产生错误 2. 以下选项中变量均已正确定义,合法的赋值语句是 ...
- MASABlazor在移动端点击保持出现悬停样式
提出问题 最近在学习MAUIBlazor,用的MASA Blazor,发现在移动端(触屏设备)上,点击会一直显示悬停样式,如下图所示,简单研究了一下,发现这是移动端的通病. 解决问题 MASABlaz ...
- CSP-S复习列表
DP:序列,区间,背包,多维,状压,树型 优化:滚动,单调性,树状数组 数据结构:栈,队,链,deque,priority_queue,vector,set,map 树状数组,分块思想 前缀和,差分思 ...
- AMH安装Nextcloud出现Access denied
AMH部署了LAMP或者LNMP,然后常规安装Nextcloud,安装完成后跳转到首页就出现Access denied.Nextcloud的文件夹权限已经修改,可读写.http://127.0.0.1 ...
- bzip2: (stdin) is not a bzip2 file.
用tar -zxvf dir.tar.gz命令解压即可.
- SwiftUI的认识与使用
SwiftUI简介 SwiftUI是苹果推出的一个新的UI框架,它使用了声明的方式,通过视图,基础控件和布局控件来进行页面的开发. SwiftUI具有跨平台性,一份SwiftUI代码可以同时跑在i ...
- 掌握Spring条件装配的秘密武器
本文分享自华为云社区<Spring高手之路9--掌握Spring条件装配的秘密武器>,作者:砖业洋__. 在Spring框架中,条件装配是一个强大的功能,可以帮助我们更好地管理和控制Bea ...
- Linux文件与目录管理核心命令:看这篇就够了
Linux文件与目录核心命令 Linux命令操作语法示例 #命令 选项 参数 command [-options] [arguments] [root@localhost ~]# ls //命令 an ...
- 网络请求-Android篇(Okhttp和Retrofit)
一.OkHttp的介绍和基本用法 OkHttp是一个流行的开源Java和Android应用程序的HTTP客户端.它由Square Inc.开发,提供了一种简单高效的方式来进行应用程序中的HTTP请求. ...