UVa1607 poj1435 UVaLive1686 Gates
填坑系列(p.246)
由函数连续性得满足二分性
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<iostream> using namespace std; void setIO(const string& s) {
freopen((s + ".in").c_str(), "r", stdin);
freopen((s + ".out").c_str(), "w", stdout);
}
template<typename Q> Q read(Q& x) {
static char c, f;
for(f = ; c = getchar(), !isdigit(c); ) if(c == '-') f = ;
for(x = ; isdigit(c); c = getchar()) x = x * + c - '';
if(f) x = -x;
return x;
}
template<typename Q> Q read() {
static Q x; read(x); return x;
} const int N = + ; int n, m;
struct Gates {
int a, b, o;
}gates[N]; int output(int k) {
for(int i = ; i <= m; i++) {
int a = gates[i].a;
int b = gates[i].b;
int va = a < ? -a > k : gates[a].o;
int vb = b < ? -b > k : gates[b].o;
gates[i].o = !(va && vb);
}
return gates[m].o;
} int solve(int vn) {
int L = , R = n;
while(L < R) {
int mid = L + (R - L) / ;
if(output(mid) == vn) R = mid; else L = mid + ;
}
return L;
} int main() {
#ifdef DEBUG
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif int T; scanf("%d", &T);
while(T--) {
scanf("%d%d", &n, &m);
for(int i = ; i <= m; i++) {
scanf("%d%d", &gates[i].a, &gates[i].b);
}
int v0 = output(), vn = output(n);
if(v0 == vn) for(int i = ; i <= n; i++) putchar('');
else {
int p = solve(vn);
for(int i = ; i < p; i++) putchar('');
putchar('x');
for(int i = p + ; i <= n; i++) putchar('');
}
puts("");
} return ;
}
UVa1607 poj1435 UVaLive1686 Gates的更多相关文章
- UVA1607 Gates 与非门电路 (二分)
题意:给你一个按发生时间的序列,表示与非门电路的输入,一开始全部输入是x,现在要改成尽量少的x,实现相同的功能. 题解:电路功能只有4中0,1,x,非x.那么如果一开始x改变了,输出结果不变,那么说明 ...
- xor和gates的专杀脚本
前段时间的一次样本,需要给出专杀,应急中遇到的是linux中比较常见的两个家族gates和xor. 首先是xor的专杀脚本,xor样本查杀的时候需要注意的是样本的主进程和子进程相互保护(详见之前的xo ...
- [Locked] Walls and Gates
Walls and Gates You are given a m x n 2D grid initialized with these three possible values. -1 - A w ...
- 【转】Memory gates checking failed because the free memory***解决办法
Issue: Vault users cannot connect. VLOGS show the following error: Memory gates checking failed beca ...
- Uva - 1607 - Gates
题目理解麻烦,估计提交量少(总共只有32个人...)也是因为题目比较麻烦,看起来像物理题,实际理解了还可以.整个电路的功能就4种,先判断x=0和x=1的输出是否相同,吐过相同,而整个电路是常熟,随便输 ...
- [转] How Bill Gates read books
Bill Gates is one of the most famous figures in the business world. He is one of the richest men in ...
- [bug]WCF 内存入口检查失败 Memory gates checking failed
bug描述 异常信息:内存入口检查失败,因为可用内存(xxx 字节)少于总内存的 xx%.因此,该服务不可用于传入的请求.若要解决此问题,请减少计算机上的负载,或调整 serviceHostingEn ...
- B. Fafa and the Gates
http://codeforces.com/problemset/problem/935/B Two neighboring kingdoms decided to build a wall betw ...
- Fafa and the Gates(模拟)
Two neighboring kingdoms decided to build a wall between them with some gates to enable the citizens ...
随机推荐
- ZOJ 1234 Chopsticks(动态规划)
Chopsticks 题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=234 题目大意:给定n个筷子的长度,取k+8套筷 ...
- SVM对偶形式
dual svm 对偶SVM linear SVM 可以用二次规划方法解 xn通过非线性转换变成zn SVM配合非线性特征转换 透过large-margin降低模型复杂度 透过特征转换得到弯弯曲曲的边 ...
- 做了五套登录页,晒一下 自己比较满意的~ oh yeh~
- WPF 进度条
//Create a Delegate that matches the Signature of the ProgressBar's SetValue method private delegate ...
- Faces.JavaServer Pages(JSP)
zhengly.cn atitit.Servlet2.5 Servlet 3.0 新特性 jsp2.0 jsp2.1 jsp2.2新特性 1.1. Servlet和JSP规范版本对应关系:1 1.2. ...
- 求算符文法的FIRSTVT集的算法
原理 数据结构 G = {'key':[v1,v2,v3],'key':[v1,v2,v3]}; VN = []; Vt = []; FirstVT = {'key':[v1,v2,v3],'key' ...
- DEDECMS 猜你喜欢
dede升级了5.7后,有个地方要求调用相关文章,于是写下 dede:likeart 标签却无法实现关联,显示的则是所有文章. 发现原来从5.5版开始已经替换了该标签,把模板中 likeart ...
- Android中UI线程与后台线程交互设计的5种方法
我想关于这个话题已经有很多前辈讨论过了.今天算是一次学习总结吧. 在android的设计思想中,为了确保用户顺滑的操作体验.一 些耗时的任务不能够在UI线程中运行,像访问网络就属于这类任务.因此我们必 ...
- C# Winform开发框架模块图(平台核心模块+示例模块)
企业版V4.0 - 模块图 企业版V4.0 - 项目解决方案 Client/Server构架,有两个解决方案: 客户端解决方案说明: 服务端解决方案说明: C/S系统开发框架- ...
- C#获取硬盘空间信息
/// <summary> /// 获取指定驱动器的空间总大小(单位为B) /// </summary> /// <param name="str_HardDi ...