ZCMU Problem A: Good Joke!
Problem A: Good Joke!
Time Limit: 1 Sec Memory Limit: 128 MB
Submit: 25 Solved: 16
[Submit][Status][Web Board]
Description
Vadim and Roman like discussing challenging problems with each other. One day Vadim told his friend following problem:
Given N points on a plane. Each point p is defined by it's two integer coordinates — px and py. The distance between points a and b is min(|ax - bx|, |ay - by|). You should choose a starting point and make a route visiting every point exactly once, i.e. if we write down numbers of points in order you visit them we should obtain a permutation. Of course, overall distance walked should be as small as possible. The number of points may be up to 40.
"40? Maybe 20? Are you kidding?" – asked Roman. "No, it's not a joke" – replied Vadim. So Roman had nothing to do, but try to solve this problem. Since Roman is really weak in problem solving and you are the only friend, except Vadim, with whom Roman can discuss challenging tasks, he has nobody else to ask for help, but you!
Input
The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.The first line of each test case contains a single integer N denoting the number of points on a plane. The following N lines contain two space-separated integers each — coordinates of points.
Constraints
- 1 ≤ T ≤ 10
- 1 ≤ N ≤ 40
- 0 ≤ absolute value of each coordinate ≤ 1000
- 1 ≤ sum over all N in a single test file ≤ 120
Output
Output the answer for every test case in a separate line. The answer for every test case is a permutation of length N. In case there are several solutions that lead to minimal distance walked, you should choose the lexicographically smallest one. Let P denote such permutation. To make output smaller, you should output H(P). H(P) = P1 xor P2 xor ... xor PN. Have a look at the example and it's explanation for better understanding.
Sample Input
3
Sample Output
HINT
天坑。
#include<stdio.h>
main()
{
int t,n; scanf("%d",&t);
while(t--)
{
int ans=0,i;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
int x,y;
scanf("%d%d",&x,&y);
ans^=i;
}
printf("%d\n",ans);
}
return 0;
}
ZCMU Problem A: Good Joke!的更多相关文章
- ZCMU Problem E: Subarray GCD(n个数的最大公约数)
Problem E: Subarray GCD Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 44 Solved: 27[Submit][Status ...
- ZCMU Problem G: 素数对(数论,素数筛法)
#include<iostream> #include<cstdlib> #include<cstring> #include<cstdio> #inc ...
- ZCMU Problem H: Crixalis's Equipment(贪心,排序)
#include<stdio.h> #include<stdlib.h> struct node { int a,b; }c[1002]; int cmpxy(const st ...
- 2010-2011 ACM-ICPC, NEERC, Moscow Subregional Contest Problem J. Joke 水题
Problem J. Joke 题目连接: http://codeforces.com/gym/100714 Description The problem is to cut the largest ...
- hdu 4946 Just a Joke(数学+物理)
链接:http://acm.hdu.edu.cn/showproblem.php?pid=4969 Just a Joke Time Limit: 2000/1000 MS (Java/Others) ...
- The Ninth Hunan Collegiate Programming Contest (2013) Problem J
Problem J Joking with Fermat's Last Theorem Fermat's Last Theorem: no three positive integers a, b, ...
- Codeforces Round #332 (Div. 2) B. Spongebob and Joke 水题
B. Spongebob and Joke Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/599 ...
- ZCMU 1894: Power Eggs
http://acm.zcmu.edu.cn/JudgeOnline/problem.php?id=1894 题意: 有M个鹰蛋,N层楼,鹰蛋的硬度是E,也就是说在1~E层楼扔下去不会碎,E+1层楼扔 ...
- ZCMU 2177 Lucky Numbers (easy)
传送门: http://acm.zcmu.edu.cn/JudgeOnline/problem.php?id=2177 2177: Lucky Numbers (easy) 时间限制: 2 Sec ...
随机推荐
- NOIP模板
快排 procedure qsort(l,r:longint); var i,j,t,m:longint; begin i:=l; j:=r; m:=a[(i+j) ]; repeat while a ...
- android中常见的命名及其特点详解
Paseal命名法 Paseal命名法特点:String MyName-DelphiInt MyAge每个单词首字母大写 Camel命名法 Camel(驼峰的意思)命名法特点:String myNam ...
- 洛谷 P2611 [ZJOI2012]小蓝的好友 解题报告
P2611 [ZJOI2012]小蓝的好友 题目描述 终于到达了这次选拔赛的最后一题,想必你已经厌倦了小蓝和小白的故事,为了回馈各位比赛选手,此题的主角是贯穿这次比赛的关键人物--小蓝的好友. 在帮小 ...
- C&C++——标准库
1.什么是C&C++的标准库? C语言被发明出来时并没有什么库函数,随着C语言的流行,越来越多的厂商或者机构组织开始提供C的编译器,并且同时把经常用到的函数封装成“库”的形式发布:不同的组织发 ...
- CSS中的@ AT规则
大家可能在CSS中见到过字符@然后加一些关键字的用法,这种用法就称之为AT规则,在CSS中,种类还是很多的,这里总结列举下. 常规规则 所谓“常规规则”指的是语法类似下面的规则: @[KEYWORD] ...
- (转)如何用python抓取网页并提取数据
最近一直在学这部分,今日发现一篇好文,虽然不详细,但是轮廓是出来了: 来自crifan:http://www.crifan.com/crawl_website_html_and_extract_inf ...
- 网络编程:connect函数
TCP客户用connect函数来建立与TCP服务器的连接: cpp #include<sys/socket.h> int connect(int sockfd, const struct ...
- Asp.Net Core 基于QuartzNet任务管理系统(这是一篇用来水的随笔)
之前一直想搞个后台任务管理系统,零零散散的搞到现在,也算完成了. 废话不多说,进入正题. github地址:https://github.com/YANGKANG01/QuartzNetJob 一.项 ...
- 搭建eova开发环境
1.安装好maven 2.下载Eova项目解压到文件夹eova下 3.dos命令到eova文件夹下执行mvn eclipse:eclipse(注:构建eclipse项目命令) 4.修改*.tag文件错 ...
- 使用FindBugs-IDEA插件找到代码中潜在的问题
另一篇使用文档,参照:https://www.cnblogs.com/huaxingtianxia/p/6703315.html 我们通常都会在APP上线之后,发现各种错误,尤其是空指针异常,这些错误 ...