当前位置:网站首页>Pat class a 1032 sharing
Pat class a 1032 sharing
2022-07-03 07:42:00 【IX. is it a non random title】
#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;
}边栏推荐
- SQL create temporary table
- Lombok -- simplify code
- 哪一刻你才发现青春结束了
- Inverted chain disk storage in Lucene (pfordelta)
- Analysis of the problems of the 7th Blue Bridge Cup single chip microcomputer provincial competition
- 一篇文章让你读懂-曼彻斯特编码
- Go language - loop statement
- Go language foundation ----- 04 ----- closure, array slice, map, package
- VMware network mode - bridge, host only, NAT network
- HCIA notes
猜你喜欢

PAT甲级 1032 Sharing

Technical dry goods | alphafold/ rosettafold open source reproduction (2) - alphafold process analysis and training Construction

技术干货|昇思MindSpore Lite1.5 特性发布,带来全新端侧AI体验

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

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

EtherCAT state machine transition (ESM)

【MySQL 12】MySQL 8.0.18 重新初始化

Go language foundation ----- 07 ----- method

Project experience sharing: realize an IR Fusion optimization pass of Shengsi mindspire layer

Iterm2设置
随机推荐
The difference between typescript let and VaR
Read config configuration file of vertx
opensips与对方tls sip trunk对接注意事项
Technical dry goods Shengsi mindspire lite1.5 feature release, bringing a new end-to-end AI experience
Go language foundation ----- 09 ----- exception handling (error, panic, recover)
Responsive MySQL of vertx
Partage de l'expérience du projet: mise en œuvre d'un pass optimisé pour la fusion IR de la couche mindstore
Go language foundation ------ 12 ------ JSON
Vertx's responsive redis client
Go language foundation ----- 18 ----- collaboration security, mutex lock, read-write lock, anonymous lock, sync Once
Project experience sharing: realize an IR Fusion optimization pass of Shengsi mindspire layer
yarn link 是如何帮助开发者对 NPM 包进行 debug 的?
Analysis of the ninth Blue Bridge Cup single chip microcomputer provincial competition
OSPF experiment
pgAdmin 4 v6.11 发布,PostgreSQL 开源图形化管理工具
华为S5700交换机初始化和配置telnet,ssh用户方法
论文学习——鄱阳湖星子站水位时间序列相似度研究
HarmonyOS第三次培训笔记
华为交换机Console密码重置、设备初始化、默认密码
Industrial resilience