当前位置:网站首页>693. 行程排序
693. 行程排序
2022-07-07 01:08:00 【Ray.C.L】

思路:找起点(入度为0),遍历一遍
代码:
#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;
}
}
边栏推荐
- 职场经历反馈给初入职场的程序员
- 关于STC单片机“假死”状态的判别
- VScode进行代码补全
- [daily training -- Tencent selected 50] 292 Nim games
- 404 not found service cannot be reached in SAP WebService test
- JVM命令之 jinfo:实时查看和修改JVM配置参数
- Get the way to optimize the one-stop worktable of customer service
- Jinfo of JVM command: view and modify JVM configuration parameters in real time
- Interview skills of software testing
- Say sqlyog deceived me!
猜你喜欢

Bbox regression loss function in target detection -l2, smooth L1, IOU, giou, Diou, ciou, focal eiou, alpha IOU, Siou
![C. colonne Swapping [tri + Simulation]](/img/0e/64d17980d3ec0051cdfb5fdb34e119.png)
C. colonne Swapping [tri + Simulation]

Determine whether the file is a DICOM file

Reading notes of Clickhouse principle analysis and Application Practice (6)
![[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

目标检测中的BBox 回归损失函数-L2,smooth L1,IoU,GIoU,DIoU,CIoU,Focal-EIoU,Alpha-IoU,SIoU

Understand the deserialization principle of fastjson for generics

Financial risk control practice - decision tree rule mining template
![[daily training -- Tencent selected 50] 235 Nearest common ancestor of binary search tree](/img/4c/16bb943e517c7b703996715632e6ca.png)
[daily training -- Tencent selected 50] 235 Nearest common ancestor of binary search tree

Chain storage of stack
随机推荐
Sequential storage of stacks
Check point: the core element for enterprises to deploy zero trust network (ztna)
On the difference between FPGA and ASIC
外设驱动库开发笔记43:GPIO模拟SPI驱动
[FPGA tutorial case 13] design and implementation of CIC filter based on vivado core
SQLSTATE[HY000][1130] Host ‘host. docker. internal‘ is not allowed to connect to this MySQL server
Bbox regression loss function in target detection -l2, smooth L1, IOU, giou, Diou, ciou, focal eiou, alpha IOU, Siou
Wechat applet Bluetooth connects hardware devices and communicates. Applet Bluetooth automatically reconnects due to abnormal distance. JS realizes CRC check bit
Classic questions about data storage
Data storage 3
PTA 天梯赛练习题集 L2-002 链表去重
[cloud native] what is the microservice architecture?
Solve pod install error: FFI is an incompatible architecture
10W word segmentation searches per second, the product manager raised another demand!!! (Collection)
Reptile exercises (III)
Flask1.1.4 Werkzeug1.0.1 源碼分析:啟動流程
R language [logic control] [mathematical operation]
Jinfo of JVM command: view and modify JVM configuration parameters in real time
pytorch_ 01 automatic derivation mechanism
如果不知道这4种缓存模式,敢说懂缓存吗?