当前位置:网站首页>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;
}
边栏推荐
- 优质博客——
- Go language foundation ----- 03 ----- process control, function, value transfer, reference transfer, defer function
- Epoll related references
- Lucene merge document order
- 项目经验分享:实现一个昇思MindSpore 图层 IR 融合优化 pass
- Go language foundation ----- 02 ----- basic data types and operators
- 技术干货|昇思MindSpore创新模型EPP-MVSNet-高精高效的三维重建
- 技术干货|昇思MindSpore可变序列长度的动态Transformer已发布!
- Various postures of CS without online line
- 在浏览器输入url后执行什么
猜你喜欢
Go language foundation ----- 13 ----- file
PAT甲级 1029 Median
技术干货|昇思MindSpore Lite1.5 特性发布,带来全新端侧AI体验
Technical dry goods Shengsi mindspire lite1.5 feature release, bringing a new end-to-end AI experience
Lucene skip table
圖像識別與檢測--筆記
技术干货|昇思MindSpore NLP模型迁移之LUKE模型——阅读理解任务
【MySQL 12】MySQL 8.0.18 重新初始化
Leetcode 213: 打家劫舍 II
The concept of C language pointer
随机推荐
Sent by mqtt client server of vertx
pgAdmin 4 v6.11 发布,PostgreSQL 开源图形化管理工具
PgSQL converts string to double type (to_number())
c语言指针的概念
华为S5700交换机初始化和配置telnet,ssh用户方法
The concept of C language pointer
Analysis of the problems of the 7th Blue Bridge Cup single chip microcomputer provincial competition
Shengsi mindspire is upgraded again, the ultimate innovation of deep scientific computing
[set theory] order relation (partial order relation | partial order set | example of partial order set)
JUnit unit test of vertx
优质博客——
Unity XR实现交互(抓取,移动旋转,传送,射击)-Pico
Industrial resilience
Go language foundation ------ 12 ------ JSON
PAT甲级 1030 Travel Plan
Technical dry goods | reproduce iccv2021 best paper swing transformer with Shengsi mindspire
Leetcode 213: looting II
Partage de l'expérience du projet: mise en œuvre d'un pass optimisé pour la fusion IR de la couche mindstore
哪一刻你才发现青春结束了
Usage of requests module