CF469

Codeforces Round #268 (Div. 2)

http://codeforces.com/contest/469

开学了,时间少,水题就不写题解了,不水的题也不写这么详细了。

A

水题

 //#pragma comment(linker, "/STACK:102400000,102400000")
#include<cstdio>
#include<cmath>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
using namespace std;
#define ll long long
#define usll unsigned ll
#define mz(array) memset(array, 0, sizeof(array))
#define mf1(array) memset(array, -1, sizeof(array))
#define minf(array) memset(array, 0x3f, sizeof(array))
#define REP(i,n) for(i=0;i<(n);i++)
#define FOR(i,x,n) for(i=(x);i<=(n);i++)
#define RD(x) scanf("%d",&x)
#define RD2(x,y) scanf("%d%d",&x,&y)
#define RD3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define WN(x) printf("%d\n",x);
#define RE freopen("D.in","r",stdin)
#define WE freopen("huzhi.txt","w",stdout)
#define mp make_pair
#define pb push_back bool a[]; int main(){
int n,m,i,x;
RD(n);
RD(m);
mz(a);
REP(i,m){RD(x);a[x]=;}
RD(m);
REP(i,m){RD(x);a[x]=;}
bool flag=;
FOR(i,,n){
if(a[i]==){flag=;break;}
}
if(flag)puts("I become the guy.");
else puts("Oh, my keyboard!");
return ;
}

B

模拟,狂撸

 //#pragma comment(linker, "/STACK:102400000,102400000")
#include<cstdio>
#include<cmath>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
using namespace std;
#define ll long long
#define usll unsigned ll
#define mz(array) memset(array, 0, sizeof(array))
#define mf1(array) memset(array, -1, sizeof(array))
#define minf(array) memset(array, 0x3f, sizeof(array))
#define REP(i,n) for(i=0;i<(n);i++)
#define FOR(i,x,n) for(i=(x);i<=(n);i++)
#define RD(x) scanf("%d",&x)
#define RD2(x,y) scanf("%d%d",&x,&y)
#define RD3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define WN(x) printf("%d\n",x);
#define RE freopen("D.in","r",stdin)
#define WE freopen("huzhi.txt","w",stdout)
#define mp make_pair
#define pb push_back int a[],b[],c[],d[];
int p,q,l,r; bool gank(int x){
int i,j;
j=;
d[q]=;
REP(i,p){
while(d[j]+x<a[i])j++;
if(j>=q)return ;
if(c[j]+x<=b[i])return ;
}
return ;
} int main(){
int i;
RD3(p,q,l);
RD(r);
REP(i,p)RD2(a[i],b[i]);
REP(i,q)RD2(c[i],d[i]);
int ans=;
FOR(i,l,r){
if(gank(i)){
// printf("%d!",i);
ans++;
}
}
WN(ans);
return ;
}

C

找规律,发现4一种5一种,更高的可以两个相邻相减搞成1,随便搞。

 //#pragma comment(linker, "/STACK:102400000,102400000")
#include<cstdio>
#include<cmath>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
using namespace std;
#define ll long long
#define usll unsigned ll
#define mz(array) memset(array, 0, sizeof(array))
#define mf1(array) memset(array, -1, sizeof(array))
#define minf(array) memset(array, 0x3f, sizeof(array))
#define REP(i,n) for(i=0;i<(n);i++)
#define FOR(i,x,n) for(i=(x);i<=(n);i++)
#define RD(x) scanf("%d",&x)
#define RD2(x,y) scanf("%d%d",&x,&y)
#define RD3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define WN(x) printf("%d\n",x);
#define RE freopen("D.in","r",stdin)
#define WE freopen("huzhi.txt","w",stdout)
#define mp make_pair
#define pb push_back void farm(int n) {
if(n<=) {
puts("NO");
return;
}
puts("YES");
while(n>) {
printf("%d - %d = 1\n",n,n-);
puts("4 * 1 = 4");
n-=;
}
if(n==) {
puts("4 * 3 = 12\n1 * 2 = 2\n2 * 12 = 24");
} else {
puts("5 - 3 = 2\n2 * 4 = 8\n2 + 1 = 3\n3 * 8 = 24");
}
} int main() {
int n;
RD(n);
farm(n);
return ;
}

D

过初审,爆炸了,还不会

发现我居然过了,不过我也不记得是啥题了怎么做的了,贴代码好了

 //#pragma comment(linker, "/STACK:102400000,102400000")
#include<cstdio>
#include<cmath>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
using namespace std;
#define ll long long
#define usll unsigned ll
#define mz(array) memset(array, 0, sizeof(array))
#define mf1(array) memset(array, -1, sizeof(array))
#define minf(array) memset(array, 0x3f, sizeof(array))
#define REP(i,n) for(i=0;i<(n);i++)
#define FOR(i,x,n) for(i=(x);i<=(n);i++)
#define RD(x) scanf("%d",&x)
#define RD2(x,y) scanf("%d%d",&x,&y)
#define RD3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define WN(x) printf("%d\n",x);
#define RE freopen("D.in","r",stdin)
#define WE freopen("huzhi.txt","w",stdout)
#define mp make_pair
#define pb push_back int d[];
int c[];
int f[];
int n,ab[]; map<int,int>S; int getfather(int x){
int t=f[x]!=x?getfather(f[x]):x;
f[x]=t;
return t;
}
void comb(int x,int y){
f[getfather(y)]=getfather(x);
} int gank(int x) {
int q=d[x];
int xa=S[ab[]-q];
int xb=S[ab[]-q];
if(xa!= && xb!=){
int fx=getfather(x);
int fxa=getfather(xa);
int fxb=getfather(xb);
if(fx>n && fxa>n && fx!=fxa)return -;
if(fx!=fxa) fx>fxa?comb(fx,fxa):comb(fxa,fx);
fx=getfather(x);
if(fx>n && fxb>n && fx!=fxb)return -;
if(fx!=fxb) fx>fxb?comb(fx,fxb):comb(fxb,fx);
}else if(xa!=){
int fx=getfather(x);
int fxa=getfather(xa);
if(fx==n+ || fxa==n+)return -;
if(fx!=n+)comb(n+,fx);
if(fxa!=n+)comb(n+,fxa);
}else if(xb!=){
int fx=getfather(x);
int fxb=getfather(xb);
if(fx==n+ || fxb==n+)return -;
if(fx!=n+)comb(n+,fx);
if(fxb!=n+)comb(n+,fxb);
}else return -;
return ;
} bool farm() {
if(ab[]==ab[])ab[]=1e9*+;
int i,j;
mf1(c);
FOR(i,,n+)f[i]=i;
///n+1��setA��n+2��setB
FOR(i,,n) {
if(gank(i)==-)return ;
//printf("%d f[1]=%d\n",i,getfather(1));
}
set<int>A;
int b[],r=;
A.clear();
int cnt=;
FOR(i,,n){
int fi=getfather(i);
if(fi!=n+ && fi!=n+){
int xa=S[ab[]-d[i]];
int xb=S[ab[]-d[i]];
if(xb!= && (getfather(xb)==n+ || i==xa))comb(n+,fi);
else if(xa!= && (getfather(xa)==n+ || i==xb)) comb(n+,fi);
else return ;
}
//printf("f[%d] = %d\n",i,f[i]);
}
return ;
} int main() {
int i;
RD3(n,ab[],ab[]);
FOR(i,,n) {
RD(d[i]);
S[d[i]]=i;
}
if(farm()) {
puts("YES");
if(n>)printf("%d",getfather()-n-);
FOR(i,,n)printf(" %d",getfather(i)-n-);
} else puts("NO");
return ;
}

Codeforces Round #268 (Div. 2) ABCD的更多相关文章

  1. Codeforces Round #258 (Div. 2)[ABCD]

    Codeforces Round #258 (Div. 2)[ABCD] ACM 题目地址:Codeforces Round #258 (Div. 2) A - Game With Sticks 题意 ...

  2. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  3. Codeforces Round #449 (Div. 2)ABCD

    又掉分了0 0. A. Scarborough Fair time limit per test 2 seconds memory limit per test 256 megabytes input ...

  4. 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 ...

  5. 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 ...

  6. Codeforces Round #143 (Div. 2) (ABCD 思维场)

    题目连链接:http://codeforces.com/contest/231 A. Team time limit per test:2 seconds memory limit per test: ...

  7. Codeforces Round #248 (Div. 2) (ABCD解决问题的方法)

    比赛链接:http://codeforces.com/contest/433 A. Kitahara Haruki's Gift time limit per test:1 second memory ...

  8. 贪心+bfs 或者 并查集 Codeforces Round #268 (Div. 2) D

    http://codeforces.com/contest/469/problem/D 题目大意: 给你一个长度为n数组,给你两个集合A.B,再给你两个数字a和b.A集合中的每一个数字x都也能在a集合 ...

  9. Codeforces Round #427 (Div. 2)——ABCD

    http://codeforces.com/contest/835 A.拼英语水平和手速的签到题 #include <bits/stdc++.h> using namespace std; ...

随机推荐

  1. 【bzoj2245】 SDOI2011—工作安排

    http://www.lydsy.com/JudgeOnline/problem.php?id=2245 (题目链接) 题意 n个产品,每个需要造C[i]件:m个员工,每个员工可以制造一些产品:每个员 ...

  2. 【bzoj2104】 K-th Number

    http://poj.org/problem?id=2104 (题目链接) 题意 求区间第k大数. Solution1 主席树裸题. 主席树当时我学是学的要死,那个时候不晓得百度出什么bug了,搜个主 ...

  3. hdu 2857 求点关于线段的对称点

    本来很简单的一个题,但是有个大坑: 因为模板中Tline用到了直线的一般方程ax+by+c=0,所以有种很坑的情况需要特判: 斜率不存在啊喂 老子坑了一下午2333 #include <math ...

  4. phpstorm取消自动保存,修改快捷键并标识修改的文件为星星标记

    编辑时间: 2016-8-3 15:15:37 个人通过使用,发现PhpStorm的确是 编辑PHP 的神器,提供用户效率,提供智能代码补全,快速导航以及即时错误检查. 不过,让我用起来不爽的是,它会 ...

  5. Alpha版本十天冲刺——Day 2

    站立式会议 会议总结 队员 今天完成 遇到的问题 明天要做 感想 鲍亮 学习post请求连接服务器,学习git 无 http资源请求方法封装,完成Android验证码获取接口和登录验证接口 今天满课, ...

  6. range和xrange梳理

    一.python2.7 range 用户获取指定范围内的数,range([start,] stop[, step]) >>> range(1,5) #代表从1到5(不包含5) [1, ...

  7. auto dock

    http://mgltools.scripps.edu/ http://mgltools.scripps.edu/downloads/previous-releases/mgltools-1-5.4/ ...

  8. python 线程编程

    在threading模块中,定义两种类型的锁:threading.Lock和threading.RLock.它们之间有一点细微的区别,通过比较下面两段代码来说明: import threading l ...

  9. maven的环境搭建

    maven环境快速搭建 最近,开发中要用到maven,所以对maven进行了简单的学习. .关于maven是什么东东,请参考其它文章. ----------------准备工作------------ ...

  10. uC/OS-II实现TEST.MAK块

    ################################################################################                     ...