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 ...
随机推荐
- Spring AOP前置通知实例讲解与AOP详细解析
一.引出问题 有个接口TestServiceInter,有两个实现方法TestService和Test2Service.他们都有sayHello():我们的需求是在调用这两个方法之前,要先完成写日志的 ...
- [Leetcode] Remove duplicate from sorted list ii 从已排序的链表中删除重复结点
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numb ...
- 安徽师大附中%你赛day6 T3 Hamsters [POI2010]CHO-Hamsters 解题报告
[POI2010]CHO-Hamsters 题意: 给出n个互不包含的字符串,要求你求出一个最短的字符串S,使得这n个字符串在S中总共至少出现m次,问S最短是多少? 范围: \(1 \le n \le ...
- 【HDU 4300 Clairewd’s message】
Clairewd is a member of FBI. After several years concealing in BUPT, she intercepted some important ...
- 使用 URLDecoder 和 URLEncoder 对中文字符进行编码和解码
原文: https://blog.csdn.net/justloveyou_/article/details/57156039 使用 URLDecoder 和 URLEncoder 对中文字符进行编码 ...
- Git命令文本手册
git init # 初始化本地git仓库(创建新仓库) git config --global user.name "xxx" # 配置用户名 git config --glob ...
- HDU2481 Toy
Time Limit: 16000/8000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission ...
- 2017年上海金马五校程序设计竞赛:Problem B : Sailing (广搜)
Description Handoku is sailing on a lake at the North Pole. The lake can be considered as a two-dime ...
- Local Authentication Using Challenge Response with Yubikey for CentOS 7
Connect Yubikey ,then initialize YubiKey slot 2: ykpersonalize -2 -ochal-resp -ochal-hmac -ohmac-lt ...
- word2vec 理论与实践
导读 本文简单的介绍了Google 于 2013 年开源推出的一个用于获取 word vector 的工具包(word2vec),并且简单的介绍了其中的两个训练模型(Skip-gram,CBOW),以 ...