CodeForces 733C Epidemic in Monstropolis
模拟。
连续的一段$a$合成一个$b$。每段中如果数字只有$1$个,那么可以合成。如果数字个数大于等于$2$个,如果都是一样的,那么无法合成,否则要找到一个可以移动的最大值位置开始移动。一开始写了一个模拟,没考虑到严格大于,$WA$在$106$组数据了......
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<ctime>
#include<iostream>
using namespace std;
typedef long long LL;
const double pi=acos(-1.0);
void File()
{
freopen("D:\\in.txt","r",stdin);
freopen("D:\\out.txt","w",stdout);
}
template <class T>
inline void read(T &x)
{
char c = getchar();
x = ;
while(!isdigit(c)) c = getchar();
while(isdigit(c))
{
x = x * + c - '';
c = getchar();
}
} int n,k;
long long a[],b[];
vector<int>p,op; int main()
{
cin>>n;
for(int i=;i<=n;i++) cin>>a[i];
cin>>k;
for(int i=;i<=k;i++) cin>>b[i]; long long sum=;
int pos=,pre=,fail=; for(int i=;i<=n;i++)
{
sum=sum+a[i];
if(sum<b[pos]) continue;
else if(sum>b[pos]) {fail=; break;}
else
{
if(i-pre==)
{
pos++; sum=; pre=i;
continue;
} bool d=;
for(int j=pre+;j<i;j++) if(a[j]!=a[j+]) d=;
if(d==) {fail=; break;} long long mx=; int idx;
for(int j=pre+;j<=i;j++) mx=max(mx,a[j]); for(int j=pre+;j<=i;j++)
{
if(a[j]!=mx) continue;
if(j->=pre+&&a[j-]!=mx)
{
idx=j;
for(int t=;t<=idx-pre-;t++) { p.push_back(idx-pre+pos--t+); op.push_back(); }
for(int t=;t<=i-idx+-;t++) { p.push_back(pos); op.push_back(); }
break;
} else if(j+<=i&&a[j+]!=mx)
{
idx=j;
for(int t=;t<=i-idx+-;t++) { p.push_back(idx-pre+pos-); op.push_back(); }
for(int t=;t<=idx-pre-;t++) { p.push_back(idx-pre+pos--t+); op.push_back(); }
break;
} } pos++; sum=; pre=i;
}
} if(pos!=k+) fail=; if(fail==) printf("NO\n");
else
{
printf("YES\n");
for(int i=;i<p.size();i++)
{
cout<<p[i]<<" ";
if(op[i]==) cout<<"L";
else cout<<"R";
cout<<endl;
}
} return ;
}
CodeForces 733C Epidemic in Monstropolis的更多相关文章
- 【16.52%】【codeforces 733C】Epidemic in Monstropolis
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- Codeforces Round #378 (Div. 2) C. Epidemic in Monstropolis 模拟
C. Epidemic in Monstropolis time limit per test 1 second memory limit per test 256 megabytes input s ...
- Codeforces Round #378 (Div. 2)-C. Epidemic in Monstropolis
C. Epidemic in Monstropolis time limit per test 1 second memory limit per test 256 megabytes input s ...
- Epidemic in Monstropolis
Epidemic in Monstropolis 题目链接:http://codeforces.com/contest/733/problem/C 贪心 新序列的m个数肯定是由原序列的连续的m个子序列 ...
- CF733C Epidemic in Monstropolis[模拟 构造 贪心]
C. Epidemic in Monstropolis time limit per test 1 second memory limit per test 256 megabytes input s ...
- Codeforces 733C:Epidemic in Monstropolis(暴力贪心)
http://codeforces.com/problemset/problem/733/C 题意:给出一个序列的怪兽体积 ai,怪兽只能吃相邻的怪兽,并且只有体积严格大于相邻的怪兽才能吃,吃完之后, ...
- C. Epidemic in Monstropolis
http://codeforces.com/contest/733/problem/C 一道很恶心的模拟题. 注意到如果能凑成b[1],那么a的前缀和一定是有一个满足是b[1]的,因为,如果跳过了一些 ...
- codeforces733-C. Epidemic in Monstropolis 贪心加链表
题意 现在有一个怪兽序列a[i],权值大的怪兽可以吃权值小的怪兽,吃完之后权值大的怪兽的权值会变成两者权值的和,相邻的怪兽才能吃 吃完之后,位置合并,队列前移,从左到右重新编号,重复这一过程, 然后给 ...
- Codeforces Round #378 (Div. 2) A B C D 施工中
A. Grasshopper And the String time limit per test 1 second memory limit per test 256 megabytes input ...
随机推荐
- Tomcat 映射虚拟目录和程序热部署
虚拟目录的设置 方法一:在${tomcat安装目录}/conf/Catalina/localhost目录下创建一个xml文件,任意文件名都可以,但是此文件名是web应用发布后的虚拟目录: 比如创建一个 ...
- 数学:Burnside引理与Pólya定理
这个计数定理在考虑对称的计数中非常有用 先给出这个定理的描述,虽然看不太懂: 在一个置换群G={a1,a2,a3……ak}中,把每个置换都写成不相交循环的乘积. 设C1(ak)是在置换ak的作用下不动 ...
- 省队集训 Day3 陈姚班
[题目大意] 给一张网格图,上往下有流量限制,下往上没有,左往右有流量限制. $n * m \leq 2.5 * 10^6$ [题解] 考场直接上最大流,50分.竟然傻逼没看出狼抓兔子. 平面图转对偶 ...
- Bzoj2832 / Bzoj3874 宅男小C
Time Limit: 10 Sec Memory Limit: 256 MBSubmit: 124 Solved: 26 Description 众所周知,小C是个宅男,所以他的每天的食物要靠外 ...
- UIImagePickerController---iOS-Apple苹果官方文档翻译
//本系列所有开发文档翻译链接地址:iOS7开发-Apple苹果iPhone开发Xcode官方文档翻译PDF下载地址 //转载请注明出处--本文永久链接:http://www.cnblogs.com ...
- Spring理论基础-面向切面编程
AOP是Aspect-Oriented Programming的缩写,中文翻译是面向切面编程.作为Spring的特征之一,是要好好学习的. 首先面向切面编程这个名称很容易让人想起面向对象编程(OOP) ...
- Vuejs - 花式渲染目标元素
Vue.js是什么 摘自官方文档: Vue (读音 /vjuː/,类似于 view) 是一套用于构建用户界面的渐进式框架.与其它大型框架不同的是,Vue 被设计为可以自底向上逐层应用.Vue 的核心库 ...
- hdu 1241Oil Deposits(BFS)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1241 Oil Deposits Time Limit: 2000/1000 MS (Java/Othe ...
- 【目录】Python自动化运维
目录:Python自动化运维笔记 Python自动化运维 - day2 - 数据类型 Python自动化运维 - day3 - 函数part1 Python自动化运维 - day4 - 函数Part2 ...
- U-Boot启动过程完全分析<转>
转载自:http://www.cnblogs.com/heaad/archive/2010/07/17/1779829.html 1.1 U-Boot工作过程 U-Boot启动内核的过程可 ...