题目链接:http://codeforces.com/problemset/problem/1166/E

说明

  1. LCM(一个集合) 为这个集合中所有元素的最小公倍数。
  2. 如果$A \subseteq B,LCM(A) \leq LCM(B)$。

题目大意

  给定由 n 个整数组成的集合 A 。现给定 m 组集合,每个集合 Si 都是 A 的一个真子集,求是否存在集合 A 使得对$\forall_{1 \leq i \leq m} \ 不等式LCM(S_i) > LCM(A - S_i)恒成立$。

分析

  考虑任意两个不同集合 Si 和 Sj,它们有两种可能情况:
  1. 无交集:$LCM(S_i) \geq LCM(A - S_i) \geq LCM(S_j) 和 LCM(S_j) \geq LCM(A - S_j) \geq LCM(S_i)矛盾$,所以只要有两个集合没有交集,A就不存在。
  2. 有交集:有交集一不一定存在 A 呢?不晓得,只能说可能,反正题目只需要输出可不可能。
  PS:用 set 做超时,自己写位图吧。

代码如下

 #include <bits/stdc++.h>
using namespace std; #define INIT() ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define Rep(i,n) for (int i = 0; i < (n); ++i)
#define For(i,s,t) for (int i = (s); i <= (t); ++i)
#define rFor(i,t,s) for (int i = (t); i >= (s); --i)
#define ForLL(i, s, t) for (LL i = LL(s); i <= LL(t); ++i)
#define rForLL(i, t, s) for (LL i = LL(t); i >= LL(s); --i)
#define foreach(i,c) for (__typeof(c.begin()) i = c.begin(); i != c.end(); ++i)
#define rforeach(i,c) for (__typeof(c.rbegin()) i = c.rbegin(); i != c.rend(); ++i) #define pr(x) cout << #x << " = " << x << " "
#define prln(x) cout << #x << " = " << x << endl #define LOWBIT(x) ((x)&(-x)) #define ALL(x) x.begin(),x.end()
#define INS(x) inserter(x,x.begin()) #define ms0(a) memset(a,0,sizeof(a))
#define msI(a) memset(a,inf,sizeof(a))
#define msM(a) memset(a,-1,sizeof(a)) #define MP make_pair
#define PB push_back
#define ft first
#define sd second template<typename T1, typename T2>
istream &operator>>(istream &in, pair<T1, T2> &p) {
in >> p.first >> p.second;
return in;
} template<typename T>
istream &operator>>(istream &in, vector<T> &v) {
for (auto &x: v)
in >> x;
return in;
} template<typename T1, typename T2>
ostream &operator<<(ostream &out, const std::pair<T1, T2> &p) {
out << "[" << p.first << ", " << p.second << "]" << "\n";
return out;
} inline int gc(){
static const int BUF = 1e7;
static char buf[BUF], *bg = buf + BUF, *ed = bg; if(bg == ed) fread(bg = buf, , BUF, stdin);
return *bg++;
} inline int ri(){
int x = , f = , c = gc();
for(; c<||c>; f = c=='-'?-:f, c=gc());
for(; c>&&c<; x = x* + c - , c=gc());
return x*f;
} typedef long long LL;
typedef unsigned long long uLL;
typedef pair< double, double > PDD;
typedef pair< int, int > PII;
typedef pair< string, int > PSI;
typedef set< int > SI;
typedef vector< int > VI;
typedef map< int, int > MII;
typedef pair< LL, LL > PLL;
typedef vector< LL > VL;
typedef vector< VL > VVL;
const double EPS = 1e-;
const LL inf = 0x7fffffff;
const LL infLL = 0x7fffffffffffffffLL;
const LL mod = 1e18 + ;
const int maxN = 1e4 + ;
const LL ONE = ;
const LL evenBits = 0xaaaaaaaaaaaaaaaa;
const LL oddBits = 0x5555555555555555; struct BitMap{
char bm[maxN >> ]; // 把第 x 位设置为 1
void set(int x){
bm[x >> ] |= 0x80 >> (x & 0x07);
}
// 把第 x 位设置为 1
void clear(int x){
bm[x >> ] &= ~(0x80 >> (x & 0x07));
}
// 获得第 x 位值
bool get(int x){
return bm[x >> ] & (0x80 >> (x & 0x07));
} bool operator& (const BitMap &x) const{
Rep(i, maxN >> ) if(bm[i] & x.bm[i]) return true;
return false;
} bool operator| (const BitMap &x) const{
Rep(i, maxN >> ) if(bm[i] | x.bm[i]) return true;
return false;
}
}; int m, n, s;
BitMap bitMask[];
bool ans = true; int main(){
INIT();
cin >> m >> n;
Rep(i, m) {
cin >> s;
Rep(j, s) {
int x;
cin >> x;
bitMask[i].set(x);
}
} Rep(i, m) {
For(j, i + , m - ) {
if(bitMask[i] & bitMask[j]) continue;
ans = false;
i = m;
break;
}
} if(ans) cout << "possible" << endl;
else cout << "impossible" << endl;
return ;
}

CodeForces 1166E The LCMs Must be Large的更多相关文章

  1. CF1166E The LCMs Must be Large

    CF1166E The LCMs Must be Large 构造趣题 正着推其实很不好推 不妨大力猜结论 如果两两集合都有交,那么一定可以 证明: 1.显然如果两个集合没有交,一定不可以 2.否则给 ...

  2. Codeforces Round #561 (Div. 2) E. The LCMs Must be Large(数学)

    传送门 题意: 有 n 个商店,第 i 个商店出售正整数 ai: Dora 买了 m 天的东西,第 i 天去了 si 个不同的个商店购买了 si 个数: Dora 的对手 Swiper 在第 i 天去 ...

  3. 【36.86%】【codeforces 558B】Amr and The Large Array

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  4. codeforces 558B B. Amr and The Large Array(水题)

    题目链接: B. Amr and The Large Array time limit per test 1 second memory limit per test 256 megabytes in ...

  5. CodeForces 1152F2 Neko Rules the Catniverse (Large Version)

    题目链接:http://codeforces.com/problemset/problem/1152/F2 题目大意 见http://codeforces.com/problemset/problem ...

  6. Codeforces 1166E(思维)

    题面 有一个长度为n的序列a,有m次操作.每一次操作一个人选a的一个子集x,另一个人会选x的补集y.且x集合中的数的最小公倍数比y集合中的数的最小公倍数大.现在给出所有x,判断是否有一个序列a满足条件 ...

  7. 降智严重——nowcoder练习赛46&&codeforces #561 Div2

    两场比赛降智不停,熬夜爆肝更掉rating nowcoder: https://ac.nowcoder.com/acm/contest/894#question T1:水题 T2:考虑a和b的子区间! ...

  8. codeforces631B

    Print Check CodeForces - 631B Kris works in a large company "Blake Technologies". As a bes ...

  9. Codeforces Round #312 (Div. 2)B. Amr and The Large Array 暴力

    B. Amr and The Large Array Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contes ...

随机推荐

  1. mui-scroll-wrapper mui-scroll 内容增多不出滚动条

    滚动条需要初始化 mui('.mui-scroll-wrapper').scroll({});

  2. console.log(([])?true:false); console.log(([]==false?true:false)); console.log(({}==false)?true:false)

    下面是题目的类型转换结果: Boolean([]); //true Number([]); //0 Number({}); // NaN Number(false); //0 因此: console. ...

  3. python 内置模块--collections

    1.计数器(counter) Counter是对字典的补充,用于追踪值出现的次数. Counter具有字典的全部属性和自己的属性. >>>import collections obj ...

  4. 学 Win32 汇编[21] - 传送指令: MOV、LEA、XCHG、XLATB、XLAT、MOVZX、MOVSX

    汇编指令的一般性要求: 1.两个操作数的尺寸必须一致; 2.操作数不能同为内存. MOV(Move): 最常用的数据传送指令 ;该指令不影响 EFlags ;指令格式: (其中的 r.m.i 分别表示 ...

  5. int在64位操作系统中占多少位?

    仍然是32位. 曾经是这样的:16位操作系统中,int 占16位:在32位操作系统中,int 占32位.但是现在人们已经习惯了 int 占32位,因此在64位操作系统中,int 仍为32位.64位整型 ...

  6. Sql生成 Insert 语句

    declare @TableName sysname select @TableName = 'T_OOSOrder' declare @result varchar(max) = 'INSERT I ...

  7. JAVA常用集合解析

    ArrayList : 底层基于数组实现,在使用add方法添加元素时,首先校验集合容量,将新添加的值放入集合尾部并进行长度加一,进行自动扩容,扩容的操作时将数据中的所有元素复制到新的集合中. 在指定位 ...

  8. JS互相调用

    JS互相调用 例1: <html> <head> <meta charset="UTF-8"> <script type="te ...

  9. MakeDown渲染出错

    MakeDown渲染出错 makedown作为程序员不可或缺的编辑工具,平时的使用技巧也是非常多的. 今天给新电脑装了一个,发现出现了错误(win10环境下),如图: 错误的表现形式即:不能实时预览M ...

  10. JAVA学习之环境搭建

    了解到JAVA语言的跨平台性的原理是通过在不同的操作系统中安装对应版本的的JAVA虚拟机(JVM)实现 开发JAVA前必须先搭建JAVA环境: 1.JAVA开发工具包JDK(JAVA DEVELOPM ...