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

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

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

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

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
亚洲国产精品成人va在线观看| 日韩欧美一区二区在线| 日韩在线观看免费网站| 欧美视频中文在线看| 精品动漫一区二区三区| 欧美激情精品久久久久久变态| 久久精品国亚洲| 精品一区精品二区| 精品香蕉一区二区三区| 久久这里有精品视频| 欧美一级免费视频| 国产精品久久久久久久久久久新郎| 久久久久久久一区二区| 成人亚洲欧美一区二区三区| 欧美久久久精品| 亚洲社区在线观看| 国产成人精品一区二区三区| 亚洲国产成人精品电影| 欧美性生活大片免费观看网址| 一本色道久久88亚洲综合88| 九九九热精品免费视频观看网站| 少妇av一区二区三区| 97在线视频免费播放| 久久国产精品影片| 欧美黑人巨大精品一区二区| 97精品一区二区三区| 91高清在线免费观看| 中文字幕欧美精品在线| 精品久久久久久久久中文字幕| 在线精品视频视频中文字幕| 欧美精品在线免费观看| 亚洲第一网站男人都懂| 国产精品久久电影观看| 亚洲自拍偷拍区| 欧美伦理91i| 国产精品网红直播| 欧美日韩国产色视频| 欧美色视频日本版| 国模gogo一区二区大胆私拍| 亚洲午夜小视频| 亚洲精品久久久久久久久久久久久| 国产激情综合五月久久| 国产精品吹潮在线观看| 韩国19禁主播vip福利视频| 亚洲国产一区二区三区在线观看| 亚洲精品自在久久| www亚洲精品| 国产日韩欧美中文| 欧美肥老太性生活视频| 国内自拍欧美激情| 色综合伊人色综合网| 国产成人精品一区二区在线| 久久99热精品这里久久精品| 国产成人免费av电影| 久久久视频免费观看| 国产精品久久久久久久久久久新郎| 亚洲男人的天堂在线| 国产一区二区黄| 伊人久久久久久久久久久久久| 在线视频一区二区| 国产精品一久久香蕉国产线看观看| 一区二区欧美日韩视频| 国产精品久久久久久久7电影| 日本精品一区二区三区在线| 亚洲成人久久久久| 欧美激情一级欧美精品| 91精品国产色综合久久不卡98口| 日韩欧美在线网址| 久久久久久久久久久免费精品| 国产精品日韩欧美综合| 亚洲精品动漫久久久久| 欧美日韩在线视频一区二区| 78m国产成人精品视频| 亚洲精选中文字幕| 久久香蕉国产线看观看av| 欧美日韩福利在线观看| 中文字幕日韩av| 国产精品黄色影片导航在线观看| 日韩在线精品一区| 91伊人影院在线播放| 国产精品三级网站| 国产精品久久久久久久久久久久久久| 日韩欧美高清在线视频| 欧美区在线播放| 国产亚洲精品久久| 久久精品视频播放| 一本大道亚洲视频| 欧美性xxxxx| 亚洲美女性视频| 欧美激情亚洲综合一区| 秋霞av国产精品一区| 亚洲97在线观看| 亚洲成人a**站| 超碰91人人草人人干| 欧美一级大片在线观看| 人体精品一二三区| 97精品免费视频| 欧美大奶子在线| 亚洲成年人影院在线| 欧美香蕉大胸在线视频观看| 欧美激情性做爰免费视频| 亚洲尤物视频网| 久久久久久免费精品| 国产亚洲一区二区精品| 亚洲人精品午夜在线观看| 国产精品极品美女粉嫩高清在线| 青青草精品毛片| 成人午夜在线观看| 久久亚洲综合国产精品99麻豆精品福利| 国产精品久久久久久久久久久久久久| 一区二区三区在线播放欧美| 欧美久久精品午夜青青大伊人| 38少妇精品导航| 国产精品电影在线观看| 亚洲爱爱爱爱爱| 欧美激情综合色综合啪啪五月| 欧美精品日韩三级| 久久这里有精品视频| 7777免费精品视频| 亚洲精品第一页| 国产精品av电影| 国产精品678| 青草热久免费精品视频| 亚洲桃花岛网站| 亚洲视频在线观看网站| 欧美黄色片免费观看| 亚洲欧美日韩爽爽影院| 97久久精品在线| 色777狠狠综合秋免鲁丝| 97在线视频观看| 亚洲国产97在线精品一区| 欧美成人精品三级在线观看| 中文字幕亚洲第一| 日韩免费av片在线观看| 91精品国产乱码久久久久久久久| 成人亚洲欧美一区二区三区| 欧美激情视频三区| 日韩欧美在线观看视频| 7777免费精品视频| 亚洲国产中文字幕在线观看| 亚洲直播在线一区| 国产成人精品视| 国产精品久久久久久久久久久新郎| 国产亚洲精品久久久久动| 亚洲国产日韩欧美在线99| 成人亚洲欧美一区二区三区| 日韩电影中文 亚洲精品乱码| 精品久久久91| 亚洲天天在线日亚洲洲精| 亚洲视频999| 在线电影欧美日韩一区二区私密| 久久久久久高潮国产精品视| 亚洲国产日韩欧美综合久久| 欧美日韩视频在线| 91av在线网站| 久久久久久成人| 色阁综合伊人av| 懂色av中文一区二区三区天美| 欧美性猛交xxxx乱大交蜜桃| 久久国产精彩视频| 国产suv精品一区二区三区88区| 欧美极品少妇与黑人| 久久久久久国产精品三级玉女聊斋| 91理论片午午论夜理片久久|