日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Find The Bone

發布時間:2024/10/5 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Find The Bone 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Description
Zane the wizard is going to perform a magic show shuffling the cups.

There are n cups, numbered from 1 to n, placed along the x-axis on a table that has m holes on it. More precisely, cup i is on the table at the position x?=?i.

The problematic bone is initially at the position x?=?1. Zane will confuse the audience by swapping the cups k times, the i-th time of which involves the cups at the positions x?=?ui and x?=?vi. If the bone happens to be at the position where there is a hole at any time, it will fall into the hole onto the ground and will not be affected by future swapping operations.

Do not forget that Zane is a wizard. When he swaps the cups, he does not move them ordinarily. Instead, he teleports the cups (along with the bone, if it is inside) to the intended positions. Therefore, for example, when he swaps the cup at x?=?4 and the one at x?=?6, they will not be at the position x?=?5 at any moment during the operation.

Zane’s puppy, Inzane, is in trouble. Zane is away on his vacation, and Inzane cannot find his beloved bone, as it would be too exhausting to try opening all the cups. Inzane knows that the Codeforces community has successfully helped Zane, so he wants to see if it could help him solve his problem too. Help Inzane determine the final position of the bone.

Input
The first line contains three integers n, m, and k (2?≤?n?≤?106, 1?≤?m?≤?n, 1?≤?k?≤?3·105) — the number of cups, the number of holes on the table, and the number of swapping operations, respectively.

The second line contains m distinct integers h1,?h2,?…,?hm (1?≤?hi?≤?n) — the positions along the x-axis where there is a hole on the table.

Each of the next k lines contains two integers ui and vi (1?≤?ui,?vi?≤?n, ui?≠?vi) — the positions of the cups to be swapped.

Output
Print one integer — the final position along the x-axis of the bone.

Examples
Input
7 3 4
3 4 6
1 2
2 5
5 7
7 1
Output
1
Input
5 1 2
2
1 2
2 4
Output
2
Note
In the first sample, after the operations, the bone becomes at x?=?2, x?=?5, x?=?7, and x?=?1, respectively.

In the second sample, after the first operation, the bone becomes at x?=?2, and falls into the hole onto the ground.

#include <stdio.h> #include <stdlib.h>/* run this program using the console pauser or add your own getch, system("pause") or input loop */ long n,m,k; long h[1000000]; int main(int argc, char *argv[]) {scanf("%ld%ld%ld",&n,&m,&k);long i,j;long temp;for(i=0;i<m;i++){scanf("%ld",&temp);h[temp]=1;}long temp1,temp2;long qiu=1;int flag=1;if(h[1]){flag=0;}else{for(i=1;i<=k;i++){scanf("%ld%ld",&temp1,&temp2);if((qiu==temp1||qiu==temp2)&&flag)qiu=temp1+temp2-qiu;if(h[qiu]==1)flag=0;}}printf("%ld\n",qiu);return 0; }

總結

以上是生活随笔為你收集整理的Find The Bone的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 国产精品久久久久永久免费看 | 波多野结衣高清视频 | 91高跟黑色丝袜呻吟动态图 | 法国少妇愉情理伦片 | 亚洲色图 欧美 | 西野翔夫の目の前で犯在线 | 狠狠躁夜夜躁人人爽天天高潮 | 国产精品av免费观看 | 欧美精品久久久久久久多人混战 | 亚洲精品久久久久久久久久久久久 | 久久免费视频3 | 精品视频一区在线观看 | 粉嫩av一区 | 欧美精品成人在线 | 爽爽影院免费观看 | 久久精品男人的天堂 | 黄色av日韩 | 国产成人精品亚洲日本在线观看 | 亚洲三级视频在线观看 | 欧美精品一二区 | 国内外成人在线视频 | 麻豆电影网站 | 国产精品av在线免费观看 | 夜夜春夜夜爽 | 黄色三级生活片 | 亚洲AV成人无码精品久久盆瓶 | 免费污片网站 | 国产一级视频免费观看 | 日韩免费三级 | 国产va在线观看 | www色日本| 精品少妇人妻av一区二区三区 | 久久久老熟女一区二区三区91 | 五月天丁香激情 | 99艹| 人人妻人人澡人人爽人人dvd | 中文在线观看免费视频 | 好吊视频在线观看 | 97香蕉碰碰人妻国产欧美 | 福利视频导航网 | 日韩欧美高清在线观看 | 国产精品aⅴ | yellow免费在线观看 | 国产一级在线观看视频 | 成人av综合网| 天天爱综合| 久久精品10| 人人爽人人草 | 顶级尤物极品女神福利视频 | 懂色av蜜臀av粉嫩av分 | 爱射网| 色久av| 成人性做爰片免费视频 | 男人的天堂aa | 国产精品网站在线 | 中日韩精品一区二区三区 | 97超碰免费在线 | 大胸美女啪啪 | 强伦轩人妻一区二区电影 | 色噜噜在线播放 | 深爱五月激情五月 | 欧美激情婷婷 | 强公把我次次高潮hd | 99亚洲欲妇| 欧美一区二区三区观看 | 户外少妇对白啪啪野战 | 国产精品视频久久久久久久 | 国产精选一区二区 | 欧美一级专区免费大片 | 女futa攻玩遍整个后宫 | 精品国产乱码久久久久久郑州公司 | 中文字幕在线视频第一页 | 高中男男gay互囗交观看 | 性色在线| 成人av动漫在线观看 | 国产精品成久久久久三级 | 51av在线| 泷泽萝拉在线播放 | 国产亚洲精品熟女国产成人 | 中文字幕一区二区久久人妻 | 黄色网址在线看 | 日韩精品一区二区三区国语自制 | 经典三级视频 | 国产激情毛片 | 高h喷汁呻吟3p | 毛片基地视频 | 四虎最新域名 | 国产成人综合亚洲 | 校园春色 亚洲色图 | 国产又粗又猛又黄视频 | 玖玖爱精品| 黄色av网址在线观看 | 日本丰满少妇做爰爽爽 | 国产一区二区在线免费观看 | 国产寡妇亲子伦一区二区三区四区 | 在线a级| 日本免费无人高清 | 成人午夜高清 | 美女被揉胸视频 |