亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

首頁 > 學院 > 開發設計 > 正文

【Codeforces 733 C. Epidemic in Monstropolis】+ 模擬

2019-11-14 10:35:07
字體:
來源:轉載
供稿:網友

C. Epidemic in Monstropolis time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output

There was an epidemic in Monstropolis and all monsters became sick. To recover, all monsters lined up in queue for an appointment to the only doctor in the city.

Soon, monsters became hungry and began to eat each other.

One monster can eat other monster if its weight is strictly greater than the weight of the monster being eaten, and they stand in the queue next to each other. Monsters eat each other instantly. There are no monsters which are being eaten at the same moment. After the monster A eats the monster B, the weight of the monster A increases by the weight of the eaten monster B. In result of such eating the length of the queue decreases by one, all monsters after the eaten one step forward so that there is no empty places in the queue again. A monster can eat several monsters one after another. Initially there were n monsters in the queue, the i-th of which had weight ai.

For example, if weights are [1,?2,?2,?2,?1,?2] (in order of queue, monsters are numbered from 1 to 6 from left to right) then some of the options are:

the first monster can't eat the second monster because a1?=?1 is not greater than a2?=?2;the second monster can't eat the third monster because a2?=?2 is not greater than a3?=?2;the second monster can't eat the fifth monster because they are not neighbors;the second monster can eat the first monster, the queue will be transformed to [3,?2,?2,?1,?2].

After some time, someone said a good joke and all monsters recovered. At that moment there were k (k?≤?n) monsters in the queue, the j-th of which had weight bj. Both sequences (a and b) contain the weights of the monsters in the order from the first to the last.

You are required to PRovide one of the possible orders of eating monsters which led to the current queue, or to determine that this could not happen. Assume that the doctor didn’t make any appointments while monsters were eating each other. Input

The first line contains single integer n (1?≤?n?≤?500) — the number of monsters in the initial queue.

The second line contains n integers a1,?a2,?…,?an (1?≤?ai?≤?106) — the initial weights of the monsters.

The third line contains single integer k (1?≤?k?≤?n) — the number of monsters in the queue after the joke.

The fourth line contains k integers b1,?b2,?…,?bk (1?≤?bj?≤?5·108) — the weights of the monsters after the joke.

Monsters are listed in the order from the beginning of the queue to the end. Output

In case if no actions could lead to the final queue, print “NO” (without quotes) in the only line.

Otherwise print “YES” (without quotes) in the first line. In the next n?-?k lines print actions in the chronological order. In each line print x — the index number of the monster in the current queue which eats and, separated by space, the symbol ‘L’ if the monster which stays the x-th in the queue eats the monster in front of him, or ‘R’ if the monster which stays the x-th in the queue eats the monster behind him. After each eating the queue is enumerated again.

When one monster eats another the queue decreases. If there are several answers, print any of them. Examples Input

6 1 2 2 2 1 2 2 5 5

Output

YES 2 L 1 R 4 L 3 L

Input

5 1 2 3 4 5 1 15

Output

YES 5 L 4 L 3 L 2 L

Input

5 1 1 1 3 3 3 2 1 6

Output

NO

Note

In the first example, initially there were n?=?6 monsters, their weights are [1,?2,?2,?2,?1,?2] (in order of queue from the first monster to the last monster). The final queue should be [5,?5]. The following sequence of eatings leads to the final queue:

the second monster eats the monster to the left (i.e. the first monster), queue becomes [3,?2,?2,?1,?2];the first monster (note, it was the second on the previous step) eats the monster to the right (i.e. the second monster), queue becomes [5,?2,?1,?2];the fourth monster eats the mosnter to the left (i.e. the third monster), queue becomes [5,?2,?3];the finally, the third monster eats the monster to the left (i.e. the second monster), queue becomes [5,?5].

Note that for each step the output contains numbers of the monsters in their current order in the queue.

模擬,在a[i]里查詢 == b[i]的數組區間l,r,判斷該段數組里的最大值能否左右去吃,用queue<pair < int,int > > q,記錄過程,

AC代碼:

#include<cstdio>#include<queue>#include<algorithm>using namespace std;queue <pair <int,int> > q;int a[510],b[510],nl,l;bool bc(int L,int R){ if(L == R) return true; int pl = L; for(int i = L; i <= R ; i++) if(a[pl] < a[i]) pl = i; if(pl > L && a[pl] > a[pl - 1]){ for(int i = pl - 1; i >= L ; i--) q.push(make_pair(i - L + nl + 1,'L')); for(int i = pl + 1; i <= R ; i++) q.push(make_pair(nl,'R')); return true; } while(a[pl] == a[pl + 1] && pl < R) pl++; if(pl < R && a[pl] > a[pl + 1]){ for(int i = pl + 1 ; i <= R; i++) q.push(make_pair(pl - L + nl,'R')); for(int i = pl - 1 ; i >= L ; i--) q.push(make_pair(i - L + nl + 1,'L')); return true; } return false;}int main(){ int sum = 0,N,M,ans = 0,t = 1; scanf("%d",&N); for(int i = 1 ; i <= N; i++) scanf("%d",&a[i]),sum += a[i]; scanf("%d",&M); for(int i = 1 ; i <= M; i++) scanf("%d",&b[i]),sum -= b[i]; l = 1,nl = 1; for(int i = 1 ; i <= N; i++){ ans += a[i]; if(ans == b[t]){ ans = 0; if(bc(l,i)) l = i + 1,nl++,t++;//printf("%d/n",l); else{ printf("NO/n");return 0; } } } if(!sum && t == M + 1){ printf("YES/n"); while(!q.empty()) printf("%d %c/n",q.front().first,q.front().second),q.pop(); } else printf("NO/n"); return 0;}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
日韩在线激情视频| 国产精品h片在线播放| 日本一区二区在线播放| 亚洲综合在线中文字幕| 国产午夜精品免费一区二区三区| 欧美夫妻性生活视频| 最近日韩中文字幕中文| 亚洲国产精久久久久久| 国产成人综合一区二区三区| 色吧影院999| 亚洲欧美精品一区| 日韩精品极品在线观看| 日韩在线激情视频| 亚洲free性xxxx护士hd| 热久久免费国产视频| 久久久久亚洲精品| 精品美女永久免费视频| 亚洲在线第一页| 国产成人福利视频| 成人黄色av免费在线观看| 久久久国产一区二区| 亚洲成人免费在线视频| 日韩视频免费大全中文字幕| 中文欧美日本在线资源| 51精品国产黑色丝袜高跟鞋| 国产亚洲免费的视频看| 欧美在线视频网站| 国产精品普通话| 国产一区二区三区18| 国产不卡视频在线| 九九九久久国产免费| 欧美又大又粗又长| 国产精品久久久久久av福利软件| 欧美激情奇米色| 日韩亚洲欧美中文在线| 亚洲最大的av网站| 欧美日韩国产中文精品字幕自在自线| 欧美激情a∨在线视频播放| 三级精品视频久久久久| 精品久久久久久中文字幕大豆网| 欧美一区二粉嫩精品国产一线天| 奇米成人av国产一区二区三区| 成人福利视频网| 国产精品久久久久久久久久久新郎| 亚洲第一区在线观看| 国产视频久久久| 久久综合88中文色鬼| 亚洲成人黄色网| 在线观看国产精品91| 日韩av一区在线观看| 日韩中文字幕免费看| 成人美女免费网站视频| 国产热re99久久6国产精品| 国产亚洲精品久久久久动| 亚洲在线第一页| 成人免费高清完整版在线观看| 色婷婷亚洲mv天堂mv在影片| 日韩成人小视频| 久久精品视频va| 日韩av一区在线| 亚洲成人精品av| 国产精品爱啪在线线免费观看| 久久久电影免费观看完整版| 91国自产精品中文字幕亚洲| 亚洲女同性videos| 亚洲综合第一页| 尤物九九久久国产精品的特点| 精品亚洲一区二区三区在线播放| 亚洲最大成人免费视频| 日韩免费av一区二区| 久久精品夜夜夜夜夜久久| 91久久在线观看| 中文字幕亚洲一区二区三区五十路| 日韩精品免费一线在线观看| 日韩av色在线| 久久免费视频在线观看| 97精品在线观看| 亚洲女人天堂网| 中文字幕精品—区二区| 2021国产精品视频| 成人444kkkk在线观看| 亚洲欧洲视频在线| 中文字幕成人精品久久不卡| 亚洲精品一区av在线播放| 久久频这里精品99香蕉| 国产欧美精品久久久| 夜夜嗨av色综合久久久综合网| 久久人91精品久久久久久不卡| 久久人91精品久久久久久不卡| 91精品久久久久久久久久久| 在线亚洲欧美视频| 日韩av不卡电影| 精品呦交小u女在线| 精品五月天久久| 亚洲一级免费视频| 欧美日韩黄色大片| 一区二区成人av| 日韩欧美国产中文字幕| 精品日本高清在线播放| 日韩在线精品视频| 久久精品成人欧美大片古装| 精品久久久在线观看| 91国产中文字幕| 欧美激情欧美激情在线五月| 欧美在线视频在线播放完整版免费观看| 日韩欧美亚洲国产一区| 韩国精品美女www爽爽爽视频| 97视频在线观看亚洲| 国内精品在线一区| 亚洲自拍欧美色图| 九色精品美女在线| 日韩av综合网站| 懂色av影视一区二区三区| 国产亚洲精品久久久优势| 尤物yw午夜国产精品视频明星| 黄色一区二区三区| 欧美洲成人男女午夜视频| 欧美美最猛性xxxxxx| 欧美视频在线观看 亚洲欧| 国产亚洲欧美日韩美女| 美女久久久久久久| 欧美中文在线观看| 午夜精品一区二区三区视频免费看| 国产精品嫩草影院一区二区| 亚洲国产精品电影| 久久精品国产69国产精品亚洲| 欧美一乱一性一交一视频| 久久久欧美精品| 亚洲女人被黑人巨大进入al| 亚洲男人第一网站| 国产在线精品成人一区二区三区| 亚洲网站在线看| 中文字幕亚洲综合久久筱田步美| 欧美日韩国产综合新一区| 在线性视频日韩欧美| 中文字幕亚洲无线码在线一区| 成人一区二区电影| 久操成人在线视频| 国产精品免费久久久久久| 久久精品成人动漫| 亚洲高清免费观看高清完整版| 久久久久久亚洲精品中文字幕| 日韩电影在线观看中文字幕| 国产精品爽爽ⅴa在线观看| 亚洲欧美制服第一页| 97婷婷大伊香蕉精品视频| 午夜精品三级视频福利| 色中色综合影院手机版在线观看| 欧美激情中文网| www国产91| 久久这里有精品视频| 亚洲欧美综合另类中字| 亚洲国产小视频在线观看| 91免费人成网站在线观看18| 蜜臀久久99精品久久久久久宅男| 国产精品久久久久久久久| 亚洲精品福利在线观看| 日韩成人激情视频| 北条麻妃久久精品| 日韩久久精品电影| 国内外成人免费激情在线视频网站| 九九精品视频在线观看| 91九色在线视频| 久久综合免费视频|