当前位置:网站首页>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 ----- 08 ----- interface
- 【LeetCode】3. Merge Two Sorted Lists·合并两个有序链表
- Technical dry goods Shengsi mindspire elementary course online: from basic concepts to practical operation, 1 hour to start!
- Leetcode 213: looting II
- PHP常用排序算法
- 华为S5700交换机初始化和配置telnet,ssh用户方法
- Iterm2设置
- VMware network mode - bridge, host only, NAT network
- lucene scorer
- Industrial resilience
猜你喜欢

Technical dry goods | reproduce iccv2021 best paper swing transformer with Shengsi mindspire

【LeetCode】2. Valid Parentheses·有效的括号

Analysis of the eighth Blue Bridge Cup single chip microcomputer provincial competition

Lucene introduces NFA

Unity XR实现交互(抓取,移动旋转,传送,射击)-Pico

Collector in ES (percentile / base)
![[Development Notes] cloud app control on device based on smart cloud 4G adapter gc211](/img/55/fea5fe315932b92993d21f861befbe.png)
[Development Notes] cloud app control on device based on smart cloud 4G adapter gc211

Technical dry goods Shengsi mindspire elementary course online: from basic concepts to practical operation, 1 hour to start!

Usage of requests module

【踩坑系列】mysql 修改root密码失败
随机推荐
华为S5700交换机初始化和配置SSH和TELNET远程登录方法
Various postures of CS without online line
【开发笔记】基于机智云4G转接板GC211的设备上云APP控制
[coppeliasim4.3] C calls UR5 in the remoteapi control scenario
Epoll related references
Analysis of the problems of the 11th Blue Bridge Cup single chip microcomputer provincial competition
Go language foundation ----- 16 ----- goroutine, GPM model
The babbage industrial policy forum
【MySQL 14】使用DBeaver工具远程备份及恢复MySQL数据库(Linux 环境)
技术干货|昇思MindSpore Lite1.5 特性发布,带来全新端侧AI体验
Segment read
技术干货|百行代码写BERT,昇思MindSpore能力大赏
What did the DFS phase do
Go language foundation ----- 18 ----- collaboration security, mutex lock, read-write lock, anonymous lock, sync Once
Robots protocol
Lucene skip table
Partage de l'expérience du projet: mise en œuvre d'un pass optimisé pour la fusion IR de la couche mindstore
TypeScript let与var的区别
OSPF experiment
Lombok cooperates with @slf4j and logback to realize logging
https://github.com/ZouJiu1/PAT