【链接】 我是链接,点我呀:)
【题意】

在这里输入题意

【题解】

i从1..n/2循环一波。
保证a[i]和a[n-i+1]就好。
如果都是2的话填上min(a,b)*2就好
其他情况跟随非2的。

【代码】

#include <bits/stdc++.h>
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define lson l,mid,rt<<1
#define ri(x) scanf("%d",&x)
#define rl(x) scanf("%lld",&x)
#define rs(x) scanf("%s",x)
#define rson mid+1,r,rt<<1|1
using namespace std;const double pi = acos(-1);
const int dx[4] = {0,0,1,-1};
const int dy[4] = {1,-1,0,0};const int N = 20;int n,a,b,cost[2];
int c[N+10];int main(){#ifdef LOCAL_DEFINEfreopen("rush_in.txt", "r", stdin);#endifscanf("%d%d%d",&n,&a,&b);cost[0] = a,cost[1] = b;rep1(i,1,n) scanf("%d",&c[i]);int ans = 0;rep1(i,1,n/2){int l = i,r = n-i+1;if (c[l]==2 && c[r]==2){ans+=min(a,b)*2;}else{if (c[l]==2){ans+=cost[c[r]];}else if (c[r]==2){ans+=cost[c[l]];}else if (c[l]!=c[r]){cout<<-1<<endl;return 0;}}}if (n&1){if (c[n/2+1]==2){ans+=min(a,b);}}printf("%d\n",ans);return 0;
}

转载于:https://www.cnblogs.com/AWCXV/p/9597251.html

【Codeforces Round #507 (Div. 2, based on Olympiad of Metropolises) A】Palindrome Dance相关推荐

  1. 【Codeforces Round #507 (Div. 2, based on Olympiad of Metropolises) B】Shashlik Cooking

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 翻转一次最多影响2k+1个地方. 如果n<=k+1 那么放在1的位置就ok.因为能覆盖1..k+1 如果n<=2k+1 ...

  2. Codeforces Round #433 (Div. 2, based on Olympiad of Metropolises)

    A. Fraction 题目链接:http://codeforces.com/contest/854/problem/A 题目意思:给出一个数n,求两个数a+b=n,且a/b不可约分,如果存在多组满足 ...

  3. 【Codeforces Round #565 (Div. 3) A B C D E F】解题报告

    Codeforces 565 失踪人口回归 cf 565 A 题意 你可以把一个偶数变成 n/2 , 可以把一个3的倍数变成 n2/3, 可以把一个5的倍数变成 n4/5 问你最少通过多少步可以变成1 ...

  4. Codeforces Round #507 (Div. 1) D. You Are Given a Tree 根号分治 + dp

    传送门 题意: 有一颗nnn个节点的树,其中一个简单路径集合被称为kkk合法当且仅当: 树的每个节点至多属于一条路径,且每条路径恰好包含kkk个点. 对于k∈[1,n]k\in [1,n]k∈[1,n ...

  5. 【Codeforces Round #767 (Div. 2)】 C. Meximum Array 题解

    [Codeforces Round #767 (Div. 2) ]C. Meximum Array 题解 1629C: Meximum Array 题解 [Codeforces Round #767 ...

  6. Codeforces Round #740 (Div. 2, based on VK Cup 2021 - Final (Engine))

    Codeforces Round #740 (Div. 2, based on VK Cup 2021 - Final (Engine)) 题号 题目 知识点 A Simply Strange Sor ...

  7. Codeforces Round #740 (Div. 2, based on VK Cup 2021 - Final (Engine)) A-F全题解

    Codeforces Round #740 (Div. 2, based on VK Cup 2021 - Final (Engine)) 文章目录 A. Simply Strange Sort B. ...

  8. C. Tyler and Strings(组合数学,树状数组维护前缀和)(Codeforces Round #775 (Div. 1, based on Moscow Open Olympiad i)

    对我来说比较困难的一题了,尝试着自己写了一下,调不出来遂放弃. Codeforces Round #775 (Div. 1, based on Moscow Open Olympiad in Info ...

  9. Codeforces Round #775 (Div. 2, based on Moscow Open Olympiad in Informatics)简训

    Codeforces Round #775 (Div. 2, based on Moscow Open Olympiad in Informatics)简训 导语 涉及的知识点 题目 A Game B ...

最新文章

  1. 这个医疗AI准确率突破天际,招来了铺天盖地的质疑
  2. Disruptor之概览
  3. ajax请求失败后重连和promiseIfy
  4. GDT,LDT,GDTR,LDTR 详解,包你理解透彻
  5. vc设置按钮文字颜色
  6. Redis基础系列-0x003:String
  7. .NET Core TLS 协议指定被我钻了空子~~~
  8. Oracle入门(十四.10)之显式游标简介
  9. 不,保持警惕不会伤害Java。 关于Java许可的评论。
  10. C++前置声明的一个好处与用法
  11. There has been an error processing your request[magento1.6]
  12. 【单片机仿真】(二)keil 安装教程
  13. everest任务栏设置
  14. 水晶易表Xcelsius 2008安装指南 支持WIN10 64位 + office2016
  15. 李迅雷:大城市化和居民加杠杆能支撑房价多久
  16. 在虚拟机中安装Neokylin操作系统
  17. 刘宇凡:七夕,听说爱情曾来过
  18. 给你一个整数 x ,如果 x 是一个回文整数,返回 true ;否则,返回 false
  19. 【HDFS】常用API
  20. Spring基础学习(一)

热门文章

  1. python程序设计语言是什么类型的语言-Python 是弱类型的语言 强类型和弱类型的语言区别...
  2. 自学python的书籍-不可错过的十本Python好书
  3. python手机软件-Python爬虫:抓取手机APP的数据
  4. python3.7和3.8的区别-Python 3.8 新功能来一波(大部分人都不知道)
  5. python批量下载网页文件-Python批量下载网页图片详细教程
  6. python语法手册-《Python 手册》pdf版电子书免费下载
  7. python程序员发展-2018年,程序员对Python有着这些期待!
  8. python绘制雷达图代码实例-python处理excel绘制雷达图
  9. python使用教程pandas-Python之Pandas使用教程
  10. python的编程模式-举例讲解Python设计模式编程中的访问者与观察者模式