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

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

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

2019-11-14 11:24:27
字體:
來源:轉載
供稿:網友

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
国产精品久久久久久av福利软件| 日韩电影中文字幕在线| 中文字幕在线日韩| 国产欧美精品日韩精品| 91精品国产综合久久久久久久久| 国产精品18久久久久久首页狼| 这里精品视频免费| 亚洲欧美中文日韩在线v日本| 欧美日韩在线观看视频小说| 在线播放国产一区二区三区| 97视频在线免费观看| 国产狼人综合免费视频| 中文字幕精品一区二区精品| 欧美精品午夜视频| 国产精品成人va在线观看| 日韩av在线免费观看一区| 深夜福利91大全| 欧美亚洲成人网| 欧美成人高清视频| 亚洲男人天堂网| 97精品伊人久久久大香线蕉| 成人福利在线观看| 日韩美女激情视频| 欧美黑人极品猛少妇色xxxxx| 久久久午夜视频| 欧美国产高跟鞋裸体秀xxxhd| 亚洲专区在线视频| 国产精品美女免费视频| 欧美日韩国产一区二区| 久久视频免费在线播放| 2018中文字幕一区二区三区| 欧美日韩美女视频| 久久精品国产综合| 久久影视电视剧免费网站清宫辞电视| 日本电影亚洲天堂| 97av在线视频免费播放| 欧美国产精品日韩| 日韩久久免费视频| 不用播放器成人网| 91豆花精品一区| 久久不射热爱视频精品| 国产精品十八以下禁看| 欧美日韩国产成人| 97精品免费视频| 在线成人中文字幕| 日韩国产在线播放| 久久精品国产欧美亚洲人人爽| 91精品国产91久久久久| 精品综合久久久久久97| 久久久精品国产网站| 欧美另类极品videosbestfree| 欧美国产日韩中文字幕在线| 国模私拍视频一区| 亚洲free性xxxx护士白浆| 久久国产精品久久久| 亚洲视频精品在线| 国语对白做受69| 日韩精品在线观| 久久人人爽人人爽人人片亚洲| 亚洲一区二区福利| 亚洲伊人一本大道中文字幕| 亚洲美女黄色片| 亚洲精品女av网站| 欧美精品第一页在线播放| 欧美性xxxx极品hd欧美风情| 日韩精品免费在线播放| 国产亚洲精品成人av久久ww| 日韩欧美中文第一页| 日韩电影网在线| 久久久999精品| 亚洲成人精品久久久| 成人免费淫片视频软件| 欧美激情精品久久久久久大尺度| 91麻豆国产精品| 欧美亚洲第一区| 精品高清美女精品国产区| 欧美精品第一页在线播放| 欧美在线亚洲在线| 在线视频亚洲欧美| 美日韩精品免费观看视频| 国产成人福利视频| 午夜精品理论片| 亚洲综合精品伊人久久| 亚洲国产高清福利视频| 中文字幕日韩欧美精品在线观看| 色中色综合影院手机版在线观看| 国产精品直播网红| 国产精彩精品视频| 久久中文字幕视频| 久久天堂av综合合色| 日韩成人在线视频| 久久6免费高清热精品| 久久精品亚洲精品| 欧美与黑人午夜性猛交久久久| 久久国产精品免费视频| 欧美日韩性生活视频| 68精品国产免费久久久久久婷婷| 美女视频久久黄| 国产中文字幕亚洲| 国外成人在线视频| 欧美高清无遮挡| 精品久久久久久久中文字幕| 欧美夫妻性视频| 91精品久久久久久久久久久| 最新中文字幕亚洲| 国产欧美久久久久久| 精品亚洲夜色av98在线观看| 精品少妇一区二区30p| 国产精品美女主播在线观看纯欲| 国产精自产拍久久久久久| 日韩精品免费在线观看| 国产成人亚洲综合青青| 国产成人自拍视频在线观看| 久热在线中文字幕色999舞| 亚洲视频免费一区| 亚洲肉体裸体xxxx137| 日韩一区二区三区国产| 亚洲精品国产精品自产a区红杏吧| 成人在线观看视频网站| 亚洲欧美激情在线视频| 国产99久久久欧美黑人| 亚洲成人黄色在线| 亚洲品质视频自拍网| 久久男人资源视频| 久久艹在线视频| 欧美与欧洲交xxxx免费观看| 亚洲午夜女主播在线直播| 亚洲变态欧美另类捆绑| 欧美高清在线视频观看不卡| 亚洲第一区在线观看| 久久97精品久久久久久久不卡| 国产精品嫩草视频| 日韩一区二区在线视频| 亚洲人精品午夜在线观看| 最近2019好看的中文字幕免费| 中文字幕久久精品| 亚洲aa中文字幕| 午夜精品一区二区三区在线视频| 草民午夜欧美限制a级福利片| 久久久av免费| 国产精品视频久久久久| 亚洲一区二区少妇| 欧美成人激情视频| 亚洲美女av网站| 国内精品模特av私拍在线观看| 久久精品男人天堂| 日本三级韩国三级久久| 国产精品久久久久久久久| 国产精品久久久久久久久久久久| 欧美激情视频一区二区| 午夜精品一区二区三区在线播放| 91香蕉亚洲精品| 国产日本欧美一区二区三区在线| 8x海外华人永久免费日韩内陆视频| 日本一区二区在线播放| 2018日韩中文字幕| 欲色天天网综合久久| 国产高清视频一区三区| 亚洲欧美制服第一页| 亚洲成人免费在线视频| 成人a级免费视频| 亚洲国产精品人久久电影| 日韩av免费一区| 日韩极品精品视频免费观看|