Codeforces Round #268 (Div. 2) (被屠记)
c被fst了。。。。。。。。。。。。。。。。
然后掉到600+.。。。
然后。。。估计得绿名了。。
sad
题意:让你判断1~n个数哪个数没有出现。。
sb题。。。开个数组即可。。
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define for1(i,a,n) for(int i=(a);i<=(n);++i)
#define for2(i,a,n) for(int i=(a);i<(n);++i)
#define for3(i,a,n) for(int i=(a);i>=(n);--i)
#define for4(i,a,n) for(int i=(a);i>(n);--i)
#define CC(i,a) memset(i,a,sizeof(i))
#define read(a) a=getint()
#define print(a) printf("%d", a)
#define dbg(x) cout << #x << " = " << x << endl
#define printarr(a, n, m) rep(aaa, n) { rep(bbb, m) cout << a[aaa][bbb]; cout << endl; }
inline const int getint() { int r=0, k=1; char c=getchar(); for(; c<'0'||c>'9'; c=getchar()) if(c=='-') k=-1; for(; c>='0'&&c<='9'; c=getchar()) r=r*10+c-'0'; return k*r; }
inline const int max(const int &a, const int &b) { return a>b?a:b; }
inline const int min(const int &a, const int &b) { return a<b?a:b; } const int N=105;
int a[N], n, p, q; int main() {
read(n);
read(p); for1(i, 1, p) a[getint()]=1;
read(q); for1(i, 1, q) a[getint()]=1;
for1(i, 1, n) if(!a[i]) { puts("Oh, my keyboard!"); return 0; }
puts("I become the guy.");
return 0;
}
题意:给你p个闭区间和q个闭区间,然后给你l和r,让你求有多少个在l-r的时间满足 将q个区间的前后加上这个时间,与p个区间有交。
枚举l~r,然后用前缀和搞搞就行了
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define for1(i,a,n) for(int i=(a);i<=(n);++i)
#define for2(i,a,n) for(int i=(a);i<(n);++i)
#define for3(i,a,n) for(int i=(a);i>=(n);--i)
#define for4(i,a,n) for(int i=(a);i>(n);--i)
#define CC(i,a) memset(i,a,sizeof(i))
#define read(a) a=getint()
#define print(a) printf("%d", a)
#define dbg(x) cout << #x << " = " << x << endl
#define printarr2(a, b, c) for1(t, 1, b) { for1(u, 1, c) cout << a[t][u]; cout << endl; }
#define printarr1(a, b) for1(t, 0, b) cout << a[t] << ' '; cout << endl
inline const int getint() { int r=0, k=1; char c=getchar(); for(; c<'0'||c>'9'; c=getchar()) if(c=='-') k=-1; for(; c>='0'&&c<='9'; c=getchar()) r=r*10+c-'0'; return k*r; }
inline const int max(const int &a, const int &b) { return a>b?a:b; }
inline const int min(const int &a, const int &b) { return a<b?a:b; } const int N=1005;
struct dat { int x, y; }a[N], b[N];
int p, q, l, r, ans, vis[N+N], mx; int main() {
read(p); read(q); read(l); read(r);
for1(i, 1, p) read(a[i].x), read(a[i].y), mx=max(mx, a[i].y);
for1(i, 1, q) read(b[i].x), read(b[i].y), mx=max(mx, b[i].y);
for1(i, l, r) {
CC(vis, 0);
for1(j, 1, p) ++vis[a[j].x], --vis[a[j].y+1];
for1(j, 1, q) ++vis[b[j].x+i], --vis[b[j].y+1+i];
int sum=0;
for1(k, 0, mx) {
sum+=vis[k];
if(sum>1) { ++ans; break; }
}
}
print(ans);
return 0;
}
C.24 Game
题意:给你n个数,分别为1~n,让你通过每次+-×两个数,然后加入到原集合中,最后剩一个数为24。。并且输出一个可行方案。。
到后边才发现。。。。只要会做1234或12345的24即可。。。后边的那些全部可以变成0或者变成1.。。。
我是写变成1的,,然后有个地方没特判,喜闻乐见被fst了。。
(我还去hack别人。。。sad。。自己的都fst了。。
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define for1(i,a,n) for(int i=(a);i<=(n);++i)
#define for2(i,a,n) for(int i=(a);i<(n);++i)
#define for3(i,a,n) for(int i=(a);i>=(n);--i)
#define for4(i,a,n) for(int i=(a);i>(n);--i)
#define CC(i,a) memset(i,a,sizeof(i))
#define read(a) a=getint()
#define print(a) printf("%d", a)
#define dbg(x) cout << #x << " = " << x << endl
#define printarr2(a, b, c) for1(i, 1, b) { for1(j, 1, c) cout << a[i][j]; cout << endl; }
#define printarr1(a, b) for1(i, 1, b) cout << a[i]; cout << endl
inline const int getint() { int r=0, k=1; char c=getchar(); for(; c<'0'||c>'9'; c=getchar()) if(c=='-') k=-1; for(; c>='0'&&c<='9'; c=getchar()) r=r*10+c-'0'; return k*r; }
inline const int max(const int &a, const int &b) { return a>b?a:b; }
inline const int min(const int &a, const int &b) { return a<b?a:b; } int n, beg=5, cnt, tot, ck;
int main() {
read(n);
if(n<4) { puts("NO"); return 0; }
puts("YES");
if(n&1) beg=6;
for(int i=beg; i<=n; i+=2) {
printf("%d - %d = 1\n", i+1, i);
++cnt;
}
tot+=cnt;
int t=cnt/2; bool flag=cnt&1; cnt=0;
for1(i, 1, t) printf("1 - 1 = 0\n"), ++cnt;
tot+=cnt;
if(flag) printf("1 * 1 = 1\n"), ++tot;
ck=tot;
for1(i, beg, n-tot-1) printf("0 + 0 = 0\n"), ++ck;
if(beg==6) {
if(n>5 && n-1-ck==5) printf("5 + 0 = 5\n");
printf("5 * 3 = 15\n");
printf("2 * 4 = 8\n");
printf("15 + 8 = 23\n");
printf("23 + 1 = 24\n");
}
else {
if(n>4 && n-1-ck==4) printf("4 + 0 = 4\n");
printf("1 + 2 = 3\n");
printf("3 + 3 = 6\n");
printf("6 * 4 = 24\n");
} return 0;
}
D.Two Sets
题意:给你n个数,在满足约束的条件下将所有数都分到对应的集合里。判断是否有解。
想到二分图,但是貌似我都不会建图?(没时间了。。。)
然后听说还可以模拟?正解是2sat?。。。orz
被吓cry。。。。。。。。这题用并查集。。
开两个并查集然后模拟加入,最后判断A和B集是否重合即可。。
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define for1(i,a,n) for(int i=(a);i<=(n);++i)
#define for2(i,a,n) for(int i=(a);i<(n);++i)
#define for3(i,a,n) for(int i=(a);i>=(n);--i)
#define for4(i,a,n) for(int i=(a);i>(n);--i)
#define CC(i,a) memset(i,a,sizeof(i))
#define read(a) a=getint()
#define print(a) printf("%d", a)
#define dbg(x) cout << #x << " = " << x << endl
#define printarr(a, n, m) rep(aaa, n) { rep(bbb, m) cout << a[aaa][bbb]; cout << endl; }
inline const int getint() { int r=0, k=1; char c=getchar(); for(; c<'0'||c>'9'; c=getchar()) if(c=='-') k=-1; for(; c>='0'&&c<='9'; c=getchar()) r=r*10+c-'0'; return k*r; }
inline const int max(const int &a, const int &b) { return a>b?a:b; }
inline const int min(const int &a, const int &b) { return a<b?a:b; } const int N=100015;
map<int, int> mp;
set<int> s;
int x[N], n, a, b, p[N], tot;
const int ifind(const int &x) { return x==p[x]?x:p[x]=ifind(p[x]); } int main() {
read(n); read(a); read(b);
for1(i, 1, n) {
read(x[i]);
s.insert(x[i]);
mp[x[i]]=++tot;
}
for1(i, 1, n+2) p[i]=i;
for1(i, 1, n) {
if(s.count(a-x[i])) {
p[ifind(mp[a-x[i]])]=p[ifind(mp[x[i]])];
}
else p[ifind(mp[x[i]])]=p[ifind(n+1)];
if(s.count(b-x[i])) {
p[ifind(mp[b-x[i]])]=p[ifind(mp[x[i]])];
}
else p[ifind(mp[x[i]])]=p[ifind(n+2)];
}
if(ifind(n+1)==ifind(n+2)) {
puts("NO"); return 0;
}
puts("YES");
for1(i, 1, n) printf("%d ", ifind(mp[x[i]])==ifind(n+1));
return 0;
}
E.Hack it!
没看题。。。。
Codeforces Round #268 (Div. 2) (被屠记)的更多相关文章
- Codeforces Round #268 (Div. 2) ABCD
CF469 Codeforces Round #268 (Div. 2) http://codeforces.com/contest/469 开学了,时间少,水题就不写题解了,不水的题也不写这么详细了 ...
- Codeforces Round #268 (Div. 1) B. Two Sets 暴力
B. Two Sets Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/468/problem/B ...
- Codeforces Round #268 (Div. 1) A. 24 Game 构造
A. 24 Game Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/468/problem/A D ...
- 贪心+bfs 或者 并查集 Codeforces Round #268 (Div. 2) D
http://codeforces.com/contest/469/problem/D 题目大意: 给你一个长度为n数组,给你两个集合A.B,再给你两个数字a和b.A集合中的每一个数字x都也能在a集合 ...
- Educational Codeforces Round 58 Div. 2 自闭记
明明多个几秒就能场上AK了.自闭. A:签到. #include<iostream> #include<cstdio> #include<cmath> #inclu ...
- Codeforces Round #268 (Div. 2)
补题解: E:只会第四种解法:也只看懂了这一种. PS:F[X+10^18]=F[X]+1;F[X]表示X的数字之和; 假设X,F[10^18+X]+F[10^18+X-1]+......F[10^1 ...
- Codeforces Round#402(Div.1)掉分记+题解
哎,今天第一次打div1 感觉头脑很不清醒... 看到第一题就蒙了,想了好久,怎么乱dp,倒过来插之类的...突然发现不就是一道sb二分吗.....sb二分看了二十分钟........ 然后第二题看了 ...
- Codeforces Round #554 (Div. 2)自闭记
A 签到 #include<bits/stdc++.h> using namespace std; ],t[],ans; int main() { scanf("%d%d&quo ...
- Codeforces Round #545 Div. 1自闭记
A:求出该行该列各有多少个比其小的取max,该行该列各有多少个比其大的取max,加起来即可. #include<iostream> #include<cstdio> #incl ...
随机推荐
- Solidworks如何隐藏零件细节,如何让零件变成一个输入
先把东西另存为IGS格式 再次打开这个IGS文件,凡是看到这个对话框都选择取消,然后确定 打开之后,还是可以看到文件结构,但是再打开每个零件都变成了输入,所以就相当于隐藏了文件细节,不知道怎么 ...
- PHP上传文件代码练习2 (重复文章)
表单: <html> <head> <meta http-equiv="Content-Type" content="text/html; ...
- java小游戏代码
一. 需求分析 曾几何时,游戏是海洛因的代名词,让人与玩物丧志联系在一起.一度遭到社会反感和家长抵制.可是.随着互联网的发展,和游戏潜在优点被发现.游戏的价值開始逐渐被社会认可,人们開始接受.认识和了 ...
- Zxing二维码扫描
源代码地址 有问题能够加QQ:312122330 之前对于Zbar的二位码扫描.到项目上线以后才发现扫描过于灵敏.导致有时候扫描到半截就启动了. 后来翻看ZXING的源代码,没有想象的复杂,复杂的地 ...
- C# Meta Programming - Let Your Code Generate Code - 利用反射重写自动的ToString()
我们在写一些Model的时候,经常会重写ToString,为了在控制台中进行打印或者更好的单元测试. 但是,如果Model的字段非常多的时候,如此简单的重复劳动经常会变成一件令人头痛的事情,因为大家 ...
- Vue 组件通信(子组件向父组件传递数据)
1.自定义事件 <!DOCTYPE html> <html lang="zh"> <head> <meta charset="U ...
- 百度URL參数解析
百度URL參数解析 在用Python爬取百度搜索的内容时,发现百度搜索的url非常的长.往往会跟一大段的參数,但事实上非常多參数都是没有必要的,如相同是搜索javakeyword,能够通过 http: ...
- C++11: reference_wrapper
https://oopscenities.net/2012/08/09/reference_wrapper/ Look at this piece of code: 1 2 3 4 5 6 7 8 9 ...
- user-defined conversion
http://en.cppreference.com/w/cpp/language/cast_operator
- Debian 的 apt 命令不能使用自动完成的问题
我的Debian是8.10,使用apt-get命令可以正常使用自动完成功能,但apt命令却不行,在国外的一个网站上找到了解决办法: 从这个地址 http://pastebin.com/PRBMt3an ...