当前位置:网站首页>PAT甲级 1032 Sharing
PAT甲级 1032 Sharing
2022-07-03 07:34:00 【九是否非随机的称呼】
#include<iostream>
#include<vector>
#include<bits/stdc++.h>
using namespace std;
int main(int argc, char **argv){
char add[100003];
int m, n, c, k, h, i, j, f;
int w, t, x, y, z;
int ind[100003];
char ch;
scanf("%d %d %d", &m, &n, &c);
for(i = 0; i < c; i++){
cin>>k>>ch>>f;
add[k] = ch;
ind[k] = f;
}
w = m;
string s, s0;
while(w!=-1){
s += add[w];
w = ind[w];
}
w = n;
while(w!=-1){
s0 += add[w];
w = ind[w];
}
reverse(s.begin(), s.end());
reverse(s0.begin(), s0.end());
char tmp;
int minmin = s.length() < s0.length()? s.length():s0.length();
w = -1;
for(i = 0; i < minmin; i++){
if(s[i]==s0[i]){
w = i;
tmp = s[w];
}
if(s[i]!=s0[i]) break;
}
t = s.length() - w - 1;
if(w < 0) cout<<"-1";
else{
x = m;
for(i = 0; i < s.length(); i++){
if(i == t) {
printf("%05d", x);
return 0;
}
x = ind[x];
}
}
return EXIT_SUCCESS;
}边栏推荐
- Vertx's responsive redis client
- The difference between typescript let and VaR
- Wireshark software usage
- Reconnaissance et détection d'images - Notes
- PdfWriter. GetInstance throws system Nullreferenceexception [en] pdfwriter GetInstance throws System. NullRef
- Arduino 软串口通信 的几点体会
- Epoll related references
- Lombok -- simplify code
- Use of generics
- 【MySQL 13】安装MySQL后第一次修改密码,可以可跳过MySQL密码验证进行登录
猜你喜欢

项目经验分享:基于昇思MindSpore实现手写汉字识别

技术干货|昇思MindSpore算子并行+异构并行,使能32卡训练2420亿参数模型

Analysis of the problems of the 10th Blue Bridge Cup single chip microcomputer provincial competition

Common architectures of IO streams

VMWare网络模式-桥接,Host-Only,NAT网络

Partage de l'expérience du projet: mise en œuvre d'un pass optimisé pour la fusion IR de la couche mindstore

技术干货|昇思MindSpore NLP模型迁移之Roberta ——情感分析任务

Understanding of class

图像识别与检测--笔记

Technical dry goods Shengsi mindspire operator parallel + heterogeneous parallel, enabling 32 card training 242 billion parameter model
随机推荐
C WinForm framework
HISAT2 - StringTie - DESeq2 pipeline 进行bulk RNA-seq
Vertx multi vertical shared data
C code production YUV420 planar format file
技术干货|昇思MindSpore NLP模型迁移之LUKE模型——阅读理解任务
Partage de l'expérience du projet: mise en œuvre d'un pass optimisé pour la fusion IR de la couche mindstore
FileInputStream and fileoutputstream
Logging log configuration of vertx
Traversal in Lucene
VMware virtual machine installation
Use of file class
Web router of vertx
圖像識別與檢測--筆記
技术干货|AI框架动静态图统一的思考
Various postures of CS without online line
技术干货|昇思MindSpore初级课程上线:从基本概念到实操,1小时上手!
Application of pigeon nest principle in Lucene minshouldmatchsumscorer
Industrial resilience
Sent by mqtt client server of vertx
The embodiment of generics in inheritance and wildcards
https://github.com/ZouJiu1/PAT