当前位置:网站首页>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;
}边栏推荐
- Technical dry goods Shengsi mindspire lite1.5 feature release, bringing a new end-to-end AI experience
- FileInputStream and fileoutputstream
- An overview of IfM Engage
- 【CoppeliaSim4.3】C#调用 remoteApi控制场景中UR5
- c语言指针的概念
- What did the DFS phase do
- List exercises after class
- 技术干货|AI框架动静态图统一的思考
- [Development Notes] cloud app control on device based on smart cloud 4G adapter gc211
- Paper learning -- Study on the similarity of water level time series of Xingzi station in Poyang Lake
猜你喜欢
![PdfWriter. GetInstance throws system Nullreferenceexception [en] pdfwriter GetInstance throws System. NullRef](/img/65/1f28071fc15e76abb37f1b128e1d90.jpg)
PdfWriter. GetInstance throws system Nullreferenceexception [en] pdfwriter GetInstance throws System. NullRef

圖像識別與檢測--筆記

带你全流程,全方位的了解属于测试的软件事故

Introduction of buffer flow

【开发笔记】基于机智云4G转接板GC211的设备上云APP控制

不出网上线CS的各种姿势

昇思MindSpore再升级,深度科学计算的极致创新

Topic | synchronous asynchronous

Collector in ES (percentile / base)

Spa single page application
随机推荐
【MySQL 14】使用DBeaver工具远程备份及恢复MySQL数据库(Linux 环境)
Qtip2 solves the problem of too many texts
Why is data service the direction of the next generation data center?
技术干货|昇思MindSpore NLP模型迁移之LUKE模型——阅读理解任务
Hello world of vertx
sharepoint 2007 versions
《指環王:力量之戒》新劇照 力量之戒鑄造者亮相
Analysis of the ninth Blue Bridge Cup single chip microcomputer provincial competition
JS monitors empty objects and empty references
C WinForm framework
Some basic operations of reflection
Chapter VI - Containers
Topic | synchronous asynchronous
Talk about floating
Leetcode 213: 打家劫舍 II
Image recognition and detection -- Notes
PdfWriter. GetInstance throws system Nullreferenceexception [en] pdfwriter GetInstance throws System. NullRef
Jeecg request URL signature
I. D3.js hello world
The babbage industrial policy forum
https://github.com/ZouJiu1/PAT