题目链接: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. noip2007 tg day1t1 统计数字

    题目描述 某次科研调查时得到了n个自然数,每个数均不超过1500000000(1.5*10^9).已知不相同的数不超过10000个,现在需要统计这些自然数各自出现的次数,并按照自然数从小到大的顺序输出 ...

  2. docker仓库管理(9)

    使用公共 Registry Docker Hub 是 Docker 公司维护的公共 Registry.用户可以将自己的镜像保存到 Docker Hub 免费的 repository 中.如果不希望别人 ...

  3. centos 下安装 shpinx2.1.7 记录

    安装sphinx yum install -y mysql mysql-devel yum install automake autoconf cd /usr/local/src/ wget http ...

  4. go语言将函数作为参数传递

    Go语言函数作为参数传递,目前给我的感觉几乎和C/C++一致.非常的灵活. import "fmt" import "time" func goFunc1(f  ...

  5. 2、Appium Desktop 使用介绍

    1.appium运行界面介绍 默认显示监控的 host 和 port , 这和 Appium-Server 中是一致的.  2.点击 “Start Server V 1.7.2” 按钮启动服务,出现如 ...

  6. 2019牛客多校第三场H-Magic Line

    Magic Line 题目传送门 解题思路 因为坐标的范围只有正负1000,且所有点坐标都是整数,所以所有点相连构成的最大斜率只有2000,而我们能够输出的的坐标范围是正负10^9.所以我们先把这n个 ...

  7. 什么是Web?

    Web这个词刚开始显得有些泛泛,似乎“冲浪”.“网上存在”以及“主页”等等都和它拉上了一些关系.甚至还有一种“Internet综合症”的说法,对许多人狂热的上网行为提出了质疑.我们在这里有必要作一些深 ...

  8. Guava Spiltter类

    Splitter 提供了各种方法来处理分割操作字符串,对象等. 类声明 以下是com.google.common.base.Splitter类的声明: @GwtCompatible(emulated= ...

  9. JSON.toJSONString()null值转“”

    public static void main(String[] s) { CybWmsCommoditiesVo cybWmsCommoditiesVo = new CybWmsCommoditie ...

  10. vue项目使用js-xlsx进行excel表格的导入和导出方法的简单原型封装

    前提:已经安装好 file-saver xlsx和 script-loader,如未安装,请查看 https://www.cnblogs.com/luyuefeng/p/8031597.html 新建 ...