Time Limit: 3000ms
Memory Limit: 65536KB
64-bit integer IO format: %lld Java class name: Main
pid=34980#" class="submitprob ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" style="margin:0px 0.1em 0px -1px; padding:0px; text-decoration:none; font-family:'Trebuchet MS',Helvetica,Arial,sans-serif; font-size:1.1em; border:1px solid rgb(204,204,204); background-color:rgb(238,238,238); font-weight:bold; color:rgb(68,68,68); display:inline-block; position:relative; zoom:1; overflow:visible">Submit
showpid=34980" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" style="margin:0px 0.1em 0px -1px; padding:0px; text-decoration:none; font-family:'Trebuchet MS',Helvetica,Arial,sans-serif; font-size:1.1em; border:1px solid rgb(204,204,204); background-color:rgb(238,238,238); font-weight:bold; color:rgb(68,68,68); display:inline-block; position:relative; zoom:1; overflow:visible">Status Statistics
pid=34980" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" style="margin:0px 0.1em 0px -1px; padding:0px; text-decoration:none; font-family:'Trebuchet MS',Helvetica,Arial,sans-serif; font-size:1.1em; border:1px solid rgb(204,204,204); background-color:rgb(238,238,238); font-weight:bold; color:rgb(68,68,68); display:inline-block; position:relative; zoom:1; overflow:visible">Discuss Next
Font Size:
Type:
None Graph Theory
2-SAT Articulation/Bridge/Biconnected Component
Cycles/Topological Sorting/Strongly Connected Component
Shortest Path
Bellman Ford Dijkstra/Floyd Warshall
Euler Trail/Circuit
Heavy-Light Decomposition
Minimum Spanning Tree
Stable Marriage Problem
Trees
Directed Minimum Spanning Tree
Flow/Matching Graph Matching
Bipartite Matching
Hopcroft–Karp Bipartite Matching
Weighted Bipartite Matching/Hungarian Algorithm
Flow
Max Flow/Min Cut
Min Cost Max Flow
DFS-like Backtracking with Pruning/Branch and Bound
Basic Recursion
IDA* Search Parsing/Grammar
Breadth First Search/Depth First Search
Advanced Search Techniques
Binary Search/Bisection
Ternary Search
Geometry
Basic Geometry Computational Geometry
Convex Hull
Pick's Theorem Game Theory
Green Hackenbush/Colon Principle/Fusion Principle
Nim
Sprague-Grundy Number
Matrix Gaussian Elimination
Matrix Exponentiation
Data Structures
Basic Data Structures
Binary Indexed Tree
Binary Search Tree
Hashing Orthogonal Range Search
Range Minimum Query/Lowest Common Ancestor
Segment Tree/Interval Tree
Trie Tree
Sorting Disjoint Set
String
Aho Corasick Knuth-Morris-Pratt
Suffix Array/Suffix Tree
Math
Basic Math Big Integer Arithmetic
Number Theory
Chinese Remainder Theorem
Extended Euclid
Inclusion/Exclusion
Modular Arithmetic
Combinatorics Group Theory/Burnside's lemma
Counting
Probability/Expected Value
Others Tricky
Hardest Unusual
Brute Force
Implementation Constructive Algorithms
Two Pointer
Bitmask Beginner
Discrete Logarithm/Shank's Baby-step Giant-step Algorithm
Greedy
Divide and Conquer
Dynamic Programming
Tag it!
师大有三宝,妹子真不少,芳姐or芳哥,认路本领好!
众所周知,师大的芳哥带队本领高强。被众粉丝尊称为“地图”!芳哥对随意时刻,随意地点。随意地形都驾轻就熟,比方校园。密室,KTV。地铁,机场,山间。田野,丘陵等等等等。
嗯,有一天芳哥带着小伙伴来到一片丘陵,这片丘陵广袤无垠,层峦叠嶂,就像一个二维数组的样子。于是芳哥花了0.2333秒记住了这片土地。
芳姐将这片丘陵分为N*M个区域,然后她记住了每一个区域的海拔。厉害吧~并且芳哥发现一个有趣的地方,就是对于同一个纬度,东边总是比西边高;对于同一个经度,南边总是比北边高。
晚上在芳哥清点人数时发现小胖不见了,赶紧打电话给小胖,小胖也不知道自己如今在哪儿,仅仅知道自己如今所在位置的海拔为K。芳哥太操心小胖以至于不能思考了,于是推断小胖是否还在这片丘陵的任务就落到了你的头上。值得欣慰的是。芳姐最多还能回答你N+M次询问,你能够询问她X,Y这个坐标的海拔是多少。假设你发现某个位置的海拔恰好等于小胖所在的海拔,那么你就觉得小胖还在这片丘陵。
假设你发现小胖还在这片丘陵,输出YES,否则输出NO。假设你没在限定的次数内推断出来。芳哥让我给你一个WA。
首先是一个整数T(T<=50),表示数据组数。
每组数据首先是三个整数N, M(1 <= N, M <= 1000), K(int范围),表示矩阵行数、列数和小胖所在的海拔。
然后对于你的程序的每一个询问,结果也会作为输入返回,保证询问结果都在int内。
在确定答案之前,每行输出一个询问,为两个整数X,Y,用空格隔开。表示询问A[X][Y]这个数是多少。
当你的程序可以推断结果时,依照题意输出一行结果 “YES” 或 “NO”(引號作为强调)。假设答案正确将直接进入下一组数据。否则本次提交结果为WA。
注意不合法的询问或推断将直接导致WA、RE或TLE。
比方这片丘陵是这个样子的:
大小为4 x 3
1 9 99
2 19 100
30 300 3000
99 999 9999
假设小胖告诉你他所在的海拔为300。一种可能推断步骤例如以下:
询问1 2
芳哥告诉你9
询问4 3
芳哥告诉你9999
询问3 2
芳哥告诉你300
这时你能够推断小胖还在这片丘陵上。
输出YES就可以。
注意:二维数组的下标从1開始。
===============================
特别鸣谢Liserious赞助题目名。
===============================
特别注意:
对于C/C++选手,请在每一个输出后加上fflush(stdout);
对于JAVA选手,请在每一个输出后加上System.out.flush();
对于Python选手,请在每一个输出后加上sys.stdout.flush()。须要import sys。
对于Pascal选手,请在每一个输出后加上Flush(StdOut)。或者使用writeln()来输出。
search=%E7%AC%AC%E5%8D%81%E4%BA%8C%E5%B1%8A%E5%8C%97%E4%BA%AC%E5%B8%88%E8%8C%83%E5%A4%A7%E5%AD%A6%E7%A8%8B%E5%BA%8F%E8%AE%BE%E8%AE%A1%E7%AB%9E%E8%B5%9B%E5%86%B3%E8%B5%9B" style="margin:0px; padding:0px; text-decoration:none; color:rgb(68,68,68); height:auto; max-width:100%">第十二届北京师范大学程序设计竞赛决赛
zhaoli
#include
#include
int n,m,k,t,nm,x,y,flag,a;
int main()
{
scanf("%d",&t);
while(t--)
{
scanf("%d%d%d",&n,&m,&k);
nm=n+m; flag=0;
x=1,y=m;//这样一定能够推断k是否在里面
while(nm)
{
nm--;
printf("%d %d\n",x,y);fflush(stdout);
scanf("%d",&a);
if(a==k)
{
printf("YES\n");flag=1;fflush(stdout);
break;
}
if(a>k)y--;
else x++;
if(x>n||y<=0)break;
}
if(flag==0)printf("NO\n"),fflush(stdout);
}
}
手机扫一扫
移动阅读更方便
你可能感兴趣的文章