当前位置:网站首页>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;
}
}
边栏推荐
- Redisl garbled code and expiration time configuration
- JVM命令之 jstat:查看JVM統計信息
- 目标检测中的损失函数与正负样本分配:RetinaNet与Focal loss
- Check Point:企业部署零信任网络(ZTNA)的核心要素
- 360织语发布7.0新品 为党政军、央国企打造专属“统一数字工作空间”
- @Detailed differences between pathvariable and @requestparam
- postgresql 数据库 timescaledb 函数time_bucket_gapfill()报错解决及更换 license
- 解决pod install报错:ffi is an incompatible architecture
- 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]
- DC-7靶机
猜你喜欢
cf:C. Column Swapping【排序 + 模拟】
苹果cms V10模板/MXone Pro自适应影视电影网站模板
Go language learning notes - Gorm use - native SQL, named parameters, rows, tosql | web framework gin (IX)
Question 102: sequence traversal of binary tree
蚂蚁庄园安全头盔 7.8蚂蚁庄园答案
Bypass open_ basedir
Vscode for code completion
一名普通学生的大一总结【不知我等是愚是狂,唯知一路向前奔驰】
JVM命令之 jstat:查看JVM统计信息
每秒10W次分词搜索,产品经理又提了一个需求!!!(收藏)
随机推荐
Flask 1.1.4 werkzeug1.0.1 analyse du code source: processus de démarrage
PTA ladder game exercise set l2-004 search tree judgment
[cloud native] what is the microservice architecture?
PTA 天梯赛练习题集 L2-002 链表去重
ML's shap: Based on the adult census income binary prediction data set (whether the predicted annual income exceeds 50K), use the shap decision diagram combined with the lightgbm model to realize the
cf:C. Column Swapping【排序 + 模拟】
vim映射大K
Experience of Niuke SQL
PTA ladder game exercise set l2-002 linked list de duplication
go-microservice-simple(2) go-Probuffer
3531. 哈夫曼树
Ctfshow-- common posture
window下面如何安装swoole
苹果cms V10模板/MXone Pro自适应影视电影网站模板
DC-7靶机
目标检测中的损失函数与正负样本分配:RetinaNet与Focal loss
生活中的开销,怎么记账合适
Introduction to the extension implementation of SAP Spartacus checkout process
话说SQLyog欺骗了我!
[FPGA tutorial case 14] design and implementation of FIR filter based on vivado core