浙江中医药大学暑期训练测试赛八B
2017-07-31 10:12
169 查看
1567: Good Joke!
Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 42 Solved: 29
[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 denotingthe 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 ≤ 101 ≤ 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
221 20 033 30 00 3Sample Output
30AC代码:
#include<iostream>
#include<algorithm>
#include<string.h>
#include<stdio.h>
using namespace std;
int 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);
}
printf("%d\n",ans);
}
return 0;
}
相关文章推荐
- 浙江中医药大学暑期训练测试赛八G
- 浙江中医药大学暑期训练测试赛八C
- 浙江中医药大学暑期训练测试赛八E
- 浙江中医药大学暑期训练测试赛十
- 浙江中医药大学暑期训练测试赛八A
- 浙江中医药大学暑期训练测试赛八F
- 浙江中医药大学暑期训练测试赛八H
- 浙江中医药大学暑期训练测试赛八I
- 浙江中医药大学暑期训练测试赛十 英雄无敌3(2) 数学公式
- 暑期测试训练3
- [深度学习] RCNNs系列(1) Ubuntu下Faster RCNN配置及训练和测试自己的数据方法
- Caffe学习:使用pycaffe进行网络训练与测试
- Coursera | Andrew Ng (02-week-1-1.1)—训练_开发_测试_数据集
- 软件安全测试实战训练
- Windos 7 64位下通过VS2013配置caffe模型,并使用MATLAB调用训练好的ImgaeNet接口做测试
- Caffe中文件参数设置(九-2):训练和测试自己的数据集-windows10版本
- caffe安装,编译(包括CUDA和cuDNN的安装),并训练,测试自己的数据(caffe使用教程)
- 机器学习和数据挖掘(5):训练与测试
- 训练和测试自己的图片
- CSU-ACM2017暑期训练1-Debug与STL C-Languages-map判重