模拟试——guess
来源:互联网 发布:java quartz 日志级别 编辑:程序博客网 时间:2024/05/21 02:37
题目大意:
题解:
因为答案要么在-10000~10000中,所以我们建一个区间[l,r],根据每一个回答去修改区间,最后输出l,如果修改过程中l>r就不用做修改了,直接输出Impossible。
如果是N,就把前面的当反语看,注意
“<”号 跟“>”号,反语是“>=”,“<=”,而不仅仅是“>”,“<”。
而<=,>=反语就仅仅只是“<”,“>”了。
时间复杂度:O(N)
var ans,i,j,k,n,l,r:longint; a,b,c,s:string;begin assign(input,'guess.in'); reset(input); assign(output,'guess.out'); rewrite(output); readln(n); l:=-10000; r:=10000; for i:=1 to n do begin readln(s); if r>=l then begin j:=pos(' ',s); a:=copy(s,1,j-1); delete(s,1,j); j:=pos(' ',s); b:=copy(s,1,j-1); delete(s,1,j); val(b,k); if s='Y' then begin if (a='>=') or (a='>') then begin if a='>' then inc(k); if k>l then l:=k; end; if (a='<') or (a='<=') then begin if a='<' then dec(k); if k<r then r:=k; end; end else begin if (a='>=') or (a='>') then begin if a='>=' then dec(k); if k<r then r:=k; end; if (a='<') or (a='<=') then begin if a='<=' then inc(k); if k>l then l:=k; end; end; end; end; if l>r then writeln('Impossible') else writeln(l); close(input); close(output);end.
阅读全文
1 0
- 模拟试——guess
- uva 1612——Guess
- game——Guess the number!
- ZOJ 3333Guess the Price(模拟)
- Guess
- guess
- Codeforces Round #245 (Div. 1)——Guess the Tree
- uva 11995——I Can Guess the Data Structure!
- Hold住Leetcode——Guess Number Higher or Lower
- LeetCode—374. Guess Number Higher or Lower
- LeetCode—375. Guess Number Higher or Lower II
- codeforces 416 A. Guess a number!(简单模拟题)
- UVA 11995I Can Guess the Data Structure!【模拟】
- 【模拟+数据结构】UVA 11995 I Can Guess the Data Structure!
- CodeForces - 618B Guess the Permutation (模拟)
- UVA11995 I Can Guess the Data Structure!(数据结构,模拟)
- UVA: I Can Guess the Data Structure!(stl模拟)
- uva——11995——I Can Guess the Data Structure!
- PCA详细讲解、ZCA、 Whitening
- JVM性能调优之生成堆的dump文件
- 事件
- 抽象类
- 深入浅出单实例SINGLETON设计模式
- 模拟试——guess
- IP问问:IP地址定位术语
- 49. Group Anagrams(第十五周)
- PostgreSQL问题解决--连接数过多
- linux 安装vsftpd
- 异常---is exceeding the 65535 bytes limit
- 操作系统思维导图
- leds-s3c24xx.c的代码逻辑
- 简介JVM的Parallel Scavenge及Parallel Old垃圾收集器