当前位置:网站首页>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;
}
}
边栏推荐
- A very good JVM interview question article (74 questions and answers)
- Financial risk control practice - decision tree rule mining template
- The boss always asks me about my progress. Don't you trust me? (what do you think)
- k8s运行oracle
- Chain storage of stack
- JVM监控及诊断工具-命令行篇
- 蚂蚁庄园安全头盔 7.8蚂蚁庄园答案
- Redisl garbled code and expiration time configuration
- [cloud native] what is the microservice architecture?
- Red hat install kernel header file
猜你喜欢

Chain storage of stack

老板总问我进展,是不信任我吗?(你觉得呢)

Reading notes of Clickhouse principle analysis and Application Practice (6)

window下面如何安装swoole

laravel 使用腾讯云 COS5全教程

A very good JVM interview question article (74 questions and answers)

Red hat install kernel header file
![[SQL practice] a SQL statistics of epidemic distribution across the country](/img/ba/639a23d87094d24572a69575b565b9.png)
[SQL practice] a SQL statistics of epidemic distribution across the country
![[cloud native] what is the microservice architecture?](/img/84/a0ec68646083f3539aa39ad9d98749.png)
[cloud native] what is the microservice architecture?
![[FPGA tutorial case 13] design and implementation of CIC filter based on vivado core](/img/19/1a6d43c39f2cf810ba754ea9674426.png)
[FPGA tutorial case 13] design and implementation of CIC filter based on vivado core
随机推荐
linear regression
Qt多线程的多种方法之一 QThread
PTA 天梯赛练习题集 L2-002 链表去重
Check point: the core element for enterprises to deploy zero trust network (ztna)
A very good JVM interview question article (74 questions and answers)
PTA TIANTI game exercise set l2-003 moon cake test point 2, test point 3 Analysis
Chain storage of stack
JVM命令之 jstat:查看JVM統計信息
软件测试知识储备:关于「登录安全」的基础知识,你了解多少?
每秒10W次分词搜索,产品经理又提了一个需求!!!(收藏)
Deep clustering: joint optimization of depth representation learning and clustering
Jcmd of JVM command: multifunctional command line
postgresql 数据库 timescaledb 函数time_bucket_gapfill()报错解决及更换 license
Experience of Niuke SQL
980. 不同路径 III DFS
laravel 使用腾讯云 COS5全教程
Nvisual network visualization
Red hat install kernel header file
10W word segmentation searches per second, the product manager raised another demand!!! (Collection)
360织语发布7.0新品 为党政军、央国企打造专属“统一数字工作空间”