当前位置:网站首页>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
边栏推荐
- 移植tslib时ts_setup: No such file or directory、ts_open: No such file or director
- MySql分组查询规则
- Find the number of leaf nodes of binary tree
- MySQL grouping query rules
- Web Course Design - his system
- 可以接收多种数据类型参数——可变参数
- 月薪10k-20k都无法回答的事务问题,你会吗?
- yes. Net future
- 2022 P cylinder filling training test questions and simulation test
- Log4net is in Net core usage
猜你喜欢

When migrating tslib_ setup: No such file or directory、ts_ open: No such file or director
![[untitled]](/img/b5/6ce72422bbf330610c747ceb482944.jpg)
[untitled]
![Idea view history [file history and project history]](/img/b2/3128105eca7449c55146ce3b9e5c2e.png)
Idea view history [file history and project history]

2022年P气瓶充装培训试题及模拟考试

Ide-idea-problem

2022T电梯修理考试模拟100题及在线模拟考试

类似Jira的十大项目管理软件

2022A特种设备相关管理(电梯)上岗证题库及模拟考试

xutils3修改了我提报的一个bug,开心

It can receive multiple data type parameters - variable parameters
随机推荐
Xamarin effect Chapter 22 recording effect
MySQL installation pit
通过 zxing 生成二维码
Super easy to use [general excel import function]
EasyUI's combobox implements three-level query
Flink实时数仓项目—DWS层设计与实现
二进制文件版本控制工具选择难?看完这篇你会找到答案
C introduction of variable parameter params
ThreadLocal 测试多线程变量实例
2022年做跨境电商五大技巧小分享
Configuration table and page information automatically generate curd operation page
《C语言程序设计》(谭浩强第五版) 第8章 善于利用指针 习题解析与答案
Preview of converting doc and PDF to SWF file
[mock data] fastmock dynamically returns the mock content according to the incoming parameters
Docker pulls MySQL and connects
软件测试相关知识~
Can you answer the questions that cannot be answered with a monthly salary of 10k-20k?
Generate QR code through zxing
可以接收多种数据类型参数——可变参数
Comprehensive calculation of employee information