当前位置:网站首页>693. Travel sequencing
693. Travel sequencing
2022-07-07 06:13:00 【Ray. C.L】

Ideas : Find a starting point ( The degree of 0), Go through it
Code :
#include <iostream>
#include <cstring>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
using namespace std;
int main()
{
int T;
cin >> T;
for(int i = 1; i <= T; i ++){
int n;
cin >> n;
unordered_map<string, string> next;
unordered_set<string> S;
while(n --){
string a, b;
cin >> a >> b;
next[a] = b;
S.insert(b);
}
string head;
for(auto& [a, b] : next)
if(!S.count(a)){
head = a;
break;
}
printf("Case #%d: ",i);
while(next[head].size()){
cout << head << '-' << next[head] << ' ';
head = next[head];
}
cout << endl;
}
}
边栏推荐
- 一名普通学生的大一总结【不知我等是愚是狂,唯知一路向前奔驰】
- On the difference between FPGA and ASIC
- Sequential storage of stacks
- 苹果cms V10模板/MXone Pro自适应影视电影网站模板
- @pathvariable 和 @Requestparam的详细区别
- Why does the data center need a set of infrastructure visual management system
- postgresql 数据库 timescaledb 函数time_bucket_gapfill()报错解决及更换 license
- Mac version PHP installed Xdebug environment (M1 version)
- Jmeter自带函数不够用?不如自己动手开发一个
- The boss always asks me about my progress. Don't you trust me? (what do you think)
猜你喜欢

【FPGA教程案例13】基于vivado核的CIC滤波器设计与实现

Jcmd of JVM command: multifunctional command line

The boss always asks me about my progress. Don't you trust me? (what do you think)

【FPGA教程案例14】基于vivado核的FIR滤波器设计与实现

Find duplicate email addresses

Subghz, lorawan, Nb IOT, Internet of things

职场经历反馈给初入职场的程序员

Red Hat安装内核头文件

驱动开发中platform设备驱动架构详解

【GNN】图解GNN: A gentle introduction(含视频)
随机推荐
Storage of dental stem cells (to be continued)
目标检测中的损失函数与正负样本分配:RetinaNet与Focal loss
Go语学习笔记 - gorm使用 - gorm处理错误 | Web框架Gin(十)
解决pod install报错:ffi is an incompatible architecture
软件测试知识储备:关于「登录安全」的基础知识,你了解多少?
Jstat of JVM command: View JVM statistics
高并发大流量秒杀方案思路
Flask 1.1.4 werkzeug1.0.1 analyse du code source: processus de démarrage
[daily training -- Tencent selected 50] 292 Nim games
What is make makefile cmake qmake and what is the difference?
Jstack of JVM command: print thread snapshots in JVM
苹果cms V10模板/MXone Pro自适应影视电影网站模板
cf:C. Column Swapping【排序 + 模擬】
Data storage 3
window下面如何安装swoole
A freshman's summary of an ordinary student [I don't know whether we are stupid or crazy, but I know to run forward all the way]
深度聚类:将深度表示学习和聚类联合优化
Value range of various datetimes in SQL Server 2008
Cloud acceleration helps you effectively solve attack problems!
Detailed explanation of platform device driver architecture in driver development