当前位置:网站首页>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
边栏推荐
- Ide-idea-problem
- Charles uses three ways to modify requests and responses
- C introduction of variable parameter params
- 2022山东省安全员C证上岗证题库及在线模拟考试
- Configuration table and page information automatically generate curd operation page
- The website JS in. Net core cefsharp chromium WebBrowser calls the C method in winfrom program
- Detailed description of MySQL index [B + tree index, hash index, full-text index, overlay index]
- Comprehensive calculation of employee information
- 场景题:A系统如何使用B系统的页面
- [MySQL] left Function | Right Function
猜你喜欢

This new feature of C 11, I would like to call it the strongest!

手机连接电脑后,QT的QDIR怎么读取手机文件路径

Chapter 7 of C language programming (fifth edition of Tan Haoqiang) analysis and answer of modular programming exercises with functions

Configuration table and page information automatically generate curd operation page

全新的ORM框架——BeetlSQL介绍

Knowledge of software testing~

A comprehensive understanding of static code analysis

《C语言程序设计》(谭浩强第五版) 第7章 用函数实现模块化程序设计 习题解析与答案

Huawei mobile ADB devices connection device is empty

2022G2电站锅炉司炉考试题库及在线模拟考试
随机推荐
JS recursive tree structure calculates the number of leaf nodes of each node and outputs it
[mock data] fastmock dynamically returns the mock content according to the incoming parameters
Explanation keyword of MySQL
Mysql database, inconsistent index character set, slow SQL query, interface timeout
Why is bi so important to enterprises?
Drawing polygons with < polygon / > circular array in SVG tag
Detailed explanation of socket programming send() and recv() functions
It can receive multiple data type parameters - variable parameters
Oracle query foreign keys contain comma separated data
批量下載文件----壓縮後再下載
月薪10k-20k都无法回答的事务问题,你会吗?
There is no index in the database table. When inserting data, SQL statements are used to prevent repeated addition (Reprint)
Blazor University (12) - component lifecycle
Xutils3 corrected a bug I reported. Happy
Docker拉取mysql并连接
2022A特种设备相关管理(电梯)上岗证题库及模拟考试
MySQL keyword group_ Concat, combined connection query
Fundamentals of software testing and development
Docker pulls MySQL and connects
手机连接电脑后,QT的QDIR怎么读取手机文件路径