当前位置:网站首页>C-11 problem h: treasure chest 2
C-11 problem h: treasure chest 2
2022-04-23 03:21:00 【Tang Encheng_ hhhc】
Problem H: Open the treasure chest 2
Time Limit: 1 Sec Memory Limit: 128 MB
Submit: 1443 Solved: 860
Description
Pioneer is a businessman , One day I found a treasure chest , The treasure box needs the right password to open . At the same time, he found a number on the chest , And a password list . There are... On the password list n A code , Only one password is correct .
The pioneer's Island has m Locations , Each location has two mysterious numbers . He gets the information he has at each location through trading , I also know that the number on this treasure chest is the label of a place x. The vanguard needs to arrive first x Location No ,x The first number on the location number is the label of the final location he is going to , The second number on the final location is the serial number of the password on the password table .
Because the treasure in the treasure chest is too valuable . Every once in a while , The numbers at some locations will change .
The pioneer wants to know the password to open this treasure chest , Smart, can you tell him directly ?
Input
Two numbers on the first line n,m.(1<=n,m<=20)
Next n A digital ai Indicates the serial number on the password table 1 The serial number n What are your passwords .(1 <=ai<=100)
Next m Two numbers on each line u,v.(1 <= u<=m,1<= v <=n)
And then I'll give you a T, Express T operations .(1<=T<= 20)
Next T That's ok , The first number in each line op, It means the first one op Kind of operation .
The first 1 Kind of operation : Then there's a number x, Represents the number on the treasure chest .(1<=x<=m).
The first 2 Kind of operation : Then there are three numbers x,u,v, Express x Change the number of location to u,v.
Output
Perform the first operation each time 1 after , Output a number to indicate the last password .( Each number accounts for 1 That's ok ).
Sample Input
5 4
1 2 3 4 5
2 4
3 3
1 2
2 5
4
1 1
2 1 4 2
1 1
1 2
Sample Output
3
5
2
#include <stdio.h>
int main()
{
int n,m;
scanf("%d%d",&n,&m);
int a[25][4];
int b[25];
for ( int i = 1;i <= n;i++)
{
scanf("%d",&b[i]);
}
for (int i = 1;i <= m;i++)
{
for (int j = 1;j <= 2;j++)
{
scanf("%d",&a[i][j]);
}
}
int T,flag,t;
scanf("%d",&T);
for (int i = 0;i < T;i++)
{
scanf("%d",&flag);
//printf("flag = %d\n",flag);
if (flag == 1)
{
scanf("%d",&t);
int p = a[t][1];
int q = a[p][2];
printf("%d\n",b[q]);
}
else
{
scanf("%d",&t);
scanf("%d%d",&a[t][1],&a[t][2]);
//printf("nnn\n");
}
}
return 0;
}
This problem is actually a paper tiger , Look hard , It just looks hard . It's hard to understand that long paragraph of reading , Understand the meaning of the topic , There's no problem at all . Also, the process will be cumbersome .
版权声明
本文为[Tang Encheng_ hhhc]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220621320150.html
边栏推荐
- Test experience data
- Idea view history [file history and project history]
- The most understandable life cycle of dependency injection
- Top ten project management software similar to JIRA
- The query type of MySQL is very inefficient.
- Data mining series (3)_ Data mining plug-in for Excel_ Estimation analysis
- socket編程 send()與 recv()函數詳解
- Mysql database
- ASP. Net 6 middleware series - conditional Middleware
- yes. Net future
猜你喜欢

Peut recevoir plusieurs paramètres de type de données - paramètres variables

ASP. Net 6 middleware series - conditional Middleware

Fiddler use

C语言实现通讯录----(静态版本)

研讨会回放视频:如何提升Jenkins能力,使其成为真正的DevOps平台

Data mining series (3)_ Data mining plug-in for Excel_ Estimation analysis

Configure automatic implementation of curd projects

《C语言程序设计》(谭浩强第五版) 第9章 用户自己建立数据类型 习题解析与答案

Course design of Database Principle -- material distribution management system

二进制文件版本控制工具选择难?看完这篇你会找到答案
随机推荐
Detailed description of MySQL index [B + tree index, hash index, full-text index, overlay index]
POI create and export Excel based on data
Top ten project management software similar to JIRA
IOTOS物联中台对接海康安防平台(iSecure Center)门禁系统
Charles uses three ways to modify requests and responses
Fight leetcode again (290. Word law)
[mock data] fastmock dynamically returns the mock content according to the incoming parameters
Iotos IOT middle platform is connected to the access control system of isecure center
2022T电梯修理考试模拟100题及在线模拟考试
二进制文件版本控制工具选择难?看完这篇你会找到答案
Explanation keyword of MySQL
Using swagger in. Net5
场景题:A系统如何使用B系统的页面
Data mining series (3)_ Data mining plug-in for Excel_ Estimation analysis
[Mysql] LEFT函数 | RIGHT函数
MySQL port is occupied when building xampp
Huawei mobile ADB devices connection device is empty
Chapter 9 of C language programming (fifth edition of Tan Haoqiang) analysis and answer of exercises for users to establish their own data types
[untitled]
一文了解全面静态代码分析