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 ...
随机推荐
- (一)centos7下如何搭建Nginx和FastDFS文件管理-环境搭建
一.关于FastDFS 1.FastDFS简介 FastDFS(Fast Distributed File System)是一个开源的分布式文件系统,旨在解决大规模文件存储和访问的问题,例如图片.音视 ...
- 春节无法线下社交聚会,来线上“一起X”共享体验
引语: 共享体验或许是全真互联网时代最显著的标志. 被疫情深刻改变的一年里,人们的社交关系和社交活动正在发生巨大的改变. 一方面,从线下转线上,我们能通过互联网连接更多的人,参与各种形式的社交活动,将 ...
- 即构SDK支持对焦、变焦、曝光调整,让直播细节清晰呈现
对焦.变焦.曝光调整,摄影爱好者对这三个术语一定不陌生. 对焦是指通过相机对焦机构变动物距和相距的位置,使被拍物成像清晰的过程:变焦指的是在望远拍摄时放大远方物体,并使之清晰成像 :曝光调整是一种曝光 ...
- PTA 21级数据结构与算法实验8—排序
目录 7-1 统计工龄 7-2 寻找大富翁 7-3 点赞狂魔 7-4 插入排序还是归并排序 7-5 插入排序还是堆排序 7-6 逆序对 7-7 堆排序 7-8 石子合并 7-9 第k小 7-10 快速 ...
- Openjob 1.0.5 发布,新增 Agent
什么是 Openjob? Openjob 基于Akka架构的新一代分布式任务调度框架.支持多种定时任务.延时任务.工作流设计,采用无中心化架构,底层使用一致性分片算法,支持无限水平扩容. 完善的任务日 ...
- Linux 软件包:添加repo、升级内核、编译内核、交叉编译
添加 repo 增加 xxx.repo 文件 在/etc/yum.repos.d/目录下创建 add_openeuler_repo.repo 文件 [add_repo] name=add_repo b ...
- tmux 移动窗格
pre + Ctrl+o:所有窗格向前移动一个位置,第一个窗格变成最后一个窗格 pre + Shift+[:当前窗格与上一个窗格交换位置 pre + Shift+]:当前窗格与下一个窗格交换位置
- Go函数可以返回多个值
1 package main 2 3 import "fmt" 4 5 func swap(x, y string) (string, string){ 6 return y,x ...
- ASP.NET WebForm中asp:Repeater和UI:Grid数据为空时如何显示表头?
一.asp:Repeater Repeater 控件用于显示被绑定在该控件上的项目的重复列表.Repeater 控件可被绑定到数据库表.XML 文件或者其他项目列表. 1.1-前台页面代码 <a ...
- debian11安装mysql5.7
前言 mysql官网5.7版本的只找到debian10的,没有debian11的,试了下也能用. 系统版本:debian 11 mysql版本:5.7.35 步骤 下载bundle的tar包.官网地址 ...