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

2
2
1 2
0 0
3
3
3
0 0
0 3

Sample Output

3
0

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!的更多相关文章

  1. ZCMU Problem E: Subarray GCD(n个数的最大公约数)

    Problem E: Subarray GCD Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 44  Solved: 27[Submit][Status ...

  2. ZCMU Problem G: 素数对(数论,素数筛法)

    #include<iostream> #include<cstdlib> #include<cstring> #include<cstdio> #inc ...

  3. ZCMU Problem H: Crixalis's Equipment(贪心,排序)

    #include<stdio.h> #include<stdlib.h> struct node { int a,b; }c[1002]; int cmpxy(const st ...

  4. 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 ...

  5. hdu 4946 Just a Joke(数学+物理)

    链接:http://acm.hdu.edu.cn/showproblem.php?pid=4969 Just a Joke Time Limit: 2000/1000 MS (Java/Others) ...

  6. 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, ...

  7. 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 ...

  8. ZCMU 1894: Power Eggs

    http://acm.zcmu.edu.cn/JudgeOnline/problem.php?id=1894 题意: 有M个鹰蛋,N层楼,鹰蛋的硬度是E,也就是说在1~E层楼扔下去不会碎,E+1层楼扔 ...

  9. ZCMU 2177 Lucky Numbers (easy)

    传送门: http://acm.zcmu.edu.cn/JudgeOnline/problem.php?id=2177 2177: Lucky Numbers (easy) 时间限制: 2 Sec   ...

随机推荐

  1. Python数据分析(四)DataFrame, Series, ndarray, list, dict, tuple的相互转换

    转自:https://blog.csdn.net/lambsnow/article/details/78517340 import numpy as np import pandas as pd ## ...

  2. [CF543D]Road Improvement

    题目大意:给定一个无根树,给每条边黑白染色,求出每个点为根时,其他点到根的路径上至多有一条黑边的染色方案数,模$1e9+7$. 题解:树形$DP$不难想到,记$f_u$为以$1$为根时,以$u$为根的 ...

  3. [NOI2017 D1T1]整数

    题目大意:有一个整数 $x$ ,一开始为 $0$ .有 $n$ 个操作,有两种类型: $1 \;a\; b$:将 $x$ 加上整数 $a\cdot 2^b$ ,其中 $a$ 为一个整数, $b$ 为一 ...

  4. angular-translate加载.json文件进行翻译

    这是这个demo的目录结构,总共有两个文件:locale-chinese.json和translation11.html locale-chinese.json文件的内容是: { "beau ...

  5. Java中中英文对齐输出问题,以及Java中的格式化输出

    一 中英文对齐输出问题 问题,要求控制台输出如下: abcefg  def 森林 阿狗 其实就是要求对齐输出,各种查找java的格式化输出,然后发现只要一个简单的“\t”就可以实现. 代码如下: Sy ...

  6. java类中获取WEB-INF路径

    WEB-INF路径 String path = WsTestBOImpl.class.getClass().getResource("/").getPath(); path = p ...

  7. POJ 3070 + 51Nod 1242 大斐波那契数取余

    POJ 3070 #include "iostream" #include "cstdio" using namespace std; class matrix ...

  8. Servlet的doGet与doPost方法的区别与使用

    Servlet的doGet与doPost方法的区别与使用 2016年07月07日 13:05:13 阅读数:10222 一,区别 在使用表单提交数据到服务器的时候有两张方式可共选择,一个是post一个 ...

  9. 哈希Hash在字符串中的应用_C++

    本文含有原创题,涉及版权利益问题,严禁转载,违者追究法律责任 哈希大家都会用撒,字符串显然都会写撒,那么哈希离散化字符串不就懂了?!(XXX的神逻辑,其实原文是:树都晓得吧,数组显然都会开呀,那么恭喜 ...

  10. [bzoj3524==bzoj2223][Poi2014]Couriers/[Coci 2009]PATULJCI——主席树+权值线段树

    题目大意 给定一个大小为n,每个数的大小均在[1,c]之间的数列,你需要回答m个询问,其中第i个询问形如\((l_i, r_i)\),你需要回答是否存在一个数使得它在区间\([l_i,r_i]\)中出 ...