11586 - Train Tracks

本文探讨了一个有趣的编程问题:如何判断一组火车轨道零件是否能拼成一个无分支、无死胡同的简单环形轨道。文章提供了输入输出示例,并附带了C语言实现的代码,该代码检查每组零件中公母接口的数量,以确定是否可以形成闭环。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Problem J: Train Tracks

Some wooden pieces

Andy loves his set of wooden trains and railroad tracks. Each day, Daddy has to build a new track for him. The tracks he likes best form a simple loop with no branches or dead ends, so he can run his trains around and around for hours until it is time for the big crash that destroys the whole construction.

So here is the question: Given a set of track pieces, can you form a simple loop with them, while using up all the pieces?

Each piece of track is described by the connectors at both ends. A standard piece has one "male" and one "female" connector. But there are also track pieces with two male or two female connectors, as shown in the front right of the picture.

To fit together, each male connector must be connected to a female connector. Unlike real wooden tracks, our pieces are assumed to be flexible, so their length or shape is not an issue here. However, you may not connect the two ends of the same piece together.

Input begins with the number of test cases. Each following line contains one test case. Each test case consists of a list of between 1 and 50 (inclusive) train track pieces. A piece is described by two code letters: M for male or F for female connector. Pieces are separated by space characters.

For each test case, output a line containing either LOOP or NO LOOP to indicate whether or not all the pieces can be joined into a single loop.

Sample input

4
MF MF
FM FF MF MM
MM FF
MF MF MF MF FF

Sample output

LOOP
LOOP
LOOP
NO LOOP
#include<stdio.h>
#include<string.h>
char a[200];
int main()
{
	int n,i;
	scanf("%d",&n);
	getchar();
	while(n--)
	{
		int m=0,f=0;
		gets(a);
		for(i=0;i<strlen(a);i++)
		{
			if(a[i]=='M') m++;
			if(a[i]=='F') f++;
		}
		if(m==f&&m!=1) puts("LOOP");
		else puts("NO LOOP");
	}
	return 0;
}


 

%******************************************************************************************************************% % The VeRi dataset is collected with 20 cameras in real-world traffic surveillance environment. % % A total of 776 vehicles are annotated. 200 vehicles are used for testing. The remaining 576 vehicles are % % for testing. % % There are 11579 images in the test set, and 37778 images in the training set. % % If you use this dataset, please kindly cite our paper as, % % % % Liu, X., Liu, W., Ma, H., Fu, H.: Large-scale vehicle re-identification in urban surveillance videos. In: IEEE % % International Conference on Multimedia and Expo. (2016) accepted. % % % % This dataset should be used for research only. Please DO NOT distribute or use it for commercial purpose. % %******************************************************************************************************************% Content in the directory: 1. "image_query/". This dir contains 1678 images as queries. 2. "image_test/". This dir contains 11579 images for testing. 3. "image_train/". This dir contains 37778 images for training. 4. "name_query.txt". It lists all query file names. 5. "name_test.txt". It lists all test file names. 6. "name_train.txt". It lists all train file names. 7. "test_track.txt". It records all test tracks. Each track contrains about 6 images of the same vehicle captured by one camera at a time. 8. "gt_image.txt". It lists the ground truths of each query in each line. 9. "jk_image.txt". It lists the junk images of each query in each line. The junk images are the images with the same camera ID to the query. 10. "train_label.xml". It lists the labels, e.g., vehicle ID, camera ID, color, type, of the training images. 11. "test_label.xml". It lists the labels of all test images. 12. "list_color.txt". It lists the numbers of colors in the xml files. 13. "list_type.txt". It lists the numbers of tpyes in the xml files. 14. "camera_ID.txt". It lists the IDs of all 20 cameras. 15. "camera_Dist.txt". It records the distances between each pair of cameras. 16. "YongtaiPoint_Google.jpg". It is the map with the camera locations. If you have any problem, please contact xinchenliu@bupt.edu.cn 翻译成中文
08-11
VeRi 数据集是一个广泛应用于车辆重识别(Vehicle Re-Identification, ReID)研究的公开数据集。以下是该数据集描述内容的中文翻译,保留了原始目录结构和相关信息: ### 数据集目录结构 ``` VeRi/ ├── image_train/ # 训练集图像 ├── image_test/ # 测试集图像 ├── image_query/ # 查询集图像 ├── train_label.xml # 训练集标签文件 ├── test_label.xml # 测试集标签文件 ├── query_label.xml # 查询集标签文件 ├── readme.txt # 数据集说明文件 ``` ### 数据集概述 VeRi 数据集由多个摄像头拍摄的车辆图像组成,涵盖了不同的视角、光照条件和时间变化。该数据集的设计旨在支持车辆重识别任务,即在不同摄像头视图中匹配相同车辆的目标。数据集包含训练集、测试集和查询集,分别用于模型训练、性能评估和实际应用测试。 ### 图像数据说明 - **训练集(image_train/)**:包含用于训练车辆重识别模型的图像,每张图像对应一个特定的车辆标识。 - **测试集(image_test/)**:用于评估模型在未知数据上的表现,包含多个摄像头拍摄的车辆图像。 - **查询集(image_query/)**:用于执行车辆匹配任务,通常包含从某一摄像头拍摄的车辆图像,目标是在测试集中找到相同车辆的其他图像。 ### 标签文件说明 - **train_label.xml**:训练集的标签文件,包含每张训练图像对应的车辆ID、摄像头ID、拍摄时间和车辆类型等信息。 - **test_label.xml**:测试集的标签文件,提供测试图像的车辆ID、摄像头ID和其他相关属性。 - **query_label.xml**:查询集的标签文件,包含查询图像的车辆ID、摄像头ID以及用于匹配的参考信息。 ### 读我文件(readme.txt) 该文件提供了数据集的基本说明,包括图像格式、标签结构、数据采集方式以及使用建议。用户在使用 VeRi 数据集前应仔细阅读此文件,以确保正确理解数据格式和使用方法。 ### 数据集特点 VeRi 数据集具有以下显著特点: - **多摄像头覆盖**:图像采集来自多个摄像头,覆盖不同道路场景,增强了数据的多样性和挑战性。 - **时间变化**:车辆在不同时间点被拍摄,模拟了真实监控系统中的时间变化因素。 - **车辆多样性**:包含多种类型的车辆,涵盖不同的品牌、颜色和型号,适用于广泛的车辆识别研究。 - **标注信息丰富**:每个图像都提供了详细的标注信息,包括车辆ID、摄像头ID、拍摄时间等,支持多维度的实验分析。 ### 适用场景 VeRi 数据集适用于以下研究方向: - 车辆重识别算法的开发与评估 - 多摄像头目标跟踪 - 车辆属性识别(如颜色、类型等) - 基于视觉的智能交通系统研究
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值