Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma GCC optimize(2)
- #include<cstdio>
- #include<cstring>
- #include<cmath>
- #include<cstdlib>
- #include<algorithm>
- #include<vector>
- #include<iostream>
- #include<queue>
- #include<functional>
- #include<bitset>
- #define lowbit(x) ((x)&(-x))
- #define Finline __inline__ __attribute__ ((always_inline))
- using std::cin;
- using std::cout;
- using std::vector;
- using std::string;
- using std::queue;
- using std::bitset;
- using std::sort;
- using std::unique;
- using std::endl;
- using std::cerr;
- using std::priority_queue;
- using std::random_shuffle;
- typedef long long ll;
- typedef unsigned int uint;
- typedef unsigned long long ull;
- const int inf=0x3f3f3f3f,Inf=0x7fffffff;
- const ll INF=0x7fffffffffffffff;
- const double eps=1e-8;
- uint seed=19260817;
- const uint _RAND_MAX_=4294967295u;
- Finline uint Rand(){return seed=seed*998244353u+1000000007u;}
- template <typename _Tp>_Tp gcd(const _Tp &a,const _Tp &b){return (!b)?a:gcd(b,a%b);}
- template <typename _Tp>Finline _Tp abs(const _Tp &a){return a>0?a:-a;}
- template <typename _Tp>Finline _Tp max(const _Tp &a,const _Tp &b){return a<b?b:a;}
- template <typename _Tp>Finline _Tp min(const _Tp &a,const _Tp &b){return a<b?a:b;}
- template <typename _Tp>Finline void chmax(_Tp &a,const _Tp &b){(a<b)&&(a=b);}
- template <typename _Tp>Finline void chmin(_Tp &a,const _Tp &b){(a>b)&&(a=b);}
- template <typename _Tp>Finline bool _cmp(const _Tp &a,const _Tp &b){return abs(a-b)<=eps;}
- template <typename _Tp>Finline void read(_Tp& x)
- {
- register char ch(getchar());
- bool VESJUMMPFA;VESJUMMPFA=18241;if (VESJUMMPFA) {
- bool GJXFPPQUSE;GJXFPPQUSE=22546;if (GJXFPPQUSE) {
- bool DOYYQEIUHD;DOYYQEIUHD=30661;if (DOYYQEIUHD) {
- if (5449>27466) {
- long long FBMBEAKFYP;
- long long MZPCYCOGEK;
- long long WBMNBZSGVN;
- bool EMVZFIBWJH;
- }
- if (24090>10395) {
- bool QTVVSBRWGN;
- int SIENYCHROL;
- long long IRCTCINCZL;
- long long IDWPUXDSDQ;
- }
- }
- }
- short LZKDROVLWX;
- if (17456>22362) {
- if (14585>31230) {
- if (5399>1871) {
- int MOULSOMLKL;
- long long YLLDXEAHYB;
- }
- if (22891>16643) {
- bool DMTSDXTYZR;
- }
- }
- if (435>21211) {
- long long SNDVODXFNJ;SNDVODXFNJ=12475;if (SNDVODXFNJ) {
- int SKKYWULEXI;
- }
- if (10110>29734) {
- int YHQLGZLBWV;
- }
- short HLFGAWGDOU;
- }
- }
- if (2622>27088) {
- long long SUXWFDMAOR;SUXWFDMAOR=31609;if (SUXWFDMAOR) {
- if (9545>3330) {
- short NNKPCHIDAM;
- }
- short MIQBPVPBYH;MIQBPVPBYH=12172;
- }
- }
- double TXQECALUHH;TXQECALUHH=16034;if (TXQECALUHH) {
- if (4647>8679) {
- double HQNKDHLDLO;HQNKDHLDLO=22367;if (HQNKDHLDLO) {
- bool DRBRVFWOGF;
- bool ADIKJFYBWG;
- bool BOGDMEIKKH;
- }
- double IVNPDKTZLK;IVNPDKTZLK=28411;if (IVNPDKTZLK) {
- int RCPTAZNNHB;
- bool QISLWAVHYB;
- bool YDJHFFWVJG;
- }
- short HPQZWTBGFC;HPQZWTBGFC=31654;
- }
- if (15195>22273) {
- short TAACEKCYHF;
- long long WTOJMJYJOE;
- int EROLJADPEF;EROLJADPEF=32574;
- if (6326>12475) {
- int HLMVJZPUDY;
- bool RNKLCXTJQY;
- int IABPTTEFEH;
- short YVCQQNFXMV;
- }
- }
- }
- }
- bool f(false);
- if (5222>14214) {
- if (4684>31672) {
- double ZCOIKJXBBH;ZCOIKJXBBH=32068;
- }
- bool NRRUGBFVSD;NRRUGBFVSD=32624;if (NRRUGBFVSD) {
- bool FEIKTRNKEW;FEIKTRNKEW=6451;if (FEIKTRNKEW) {
- int EFHPFSCIJJ;
- long long BAKVYEJLEU;BAKVYEJLEU=21394;
- bool MKBDXHVXLS;MKBDXHVXLS=16739;
- }
- bool PKEFWSTFIJ;
- double ZBPEBTGXTW;ZBPEBTGXTW=7801;
- }
- }
- while(ch<48||ch>57) f|=ch==45,ch=getchar();
- if (894>15420) {
- if (25477>28968) {
- if (16167>3293) {
- if (19221>22878) {
- long long VEWOVRDVEY;
- bool GTZRGHGUMD;
- }
- }
- }
- double NBDXDLFPZS;NBDXDLFPZS=27346;
- long long YITYKHITAP;
- int LTDCSRQAOQ;LTDCSRQAOQ=12875;if (LTDCSRQAOQ) {
- if (28281>29540) {
- if (23747>5776) {
- short TAIIBHYLRP;
- bool PEHCOSCWYW;
- double SHRYSWKINI;
- bool NXMQRSEQHS;
- }
- if (30241>9864) {
- long long XZUYEPHLIF;
- int RSHYVUMBTE;
- long long OLDYPGOBLY;
- }
- long long FMCFLFPGZX;
- if (257>12400) {
- long long MZXVFVUSKP;
- double HCGUXAQOFX;
- }
- }
- long long YLKPVYQCXN;
- double YGCDDWZYPN;YGCDDWZYPN=9548;if (YGCDDWZYPN) {
- double IQVRUFDMBH;IQVRUFDMBH=376;
- double TKKFZUNXNZ;TKKFZUNXNZ=7616;
- }
- if (783>26708) {
- int YIALVJOUHV;
- if (16007>12152) {
- short AFEYBMSYXW;
- bool ZJIETKGNDF;
- }
- bool PGLOQCNCLJ;PGLOQCNCLJ=29132;if (PGLOQCNCLJ) {
- long long YCYERNHZBM;
- }
- if (11260>8166) {
- short ZATMNCVLRU;
- }
- bool WNGDORYWCH;WNGDORYWCH=21564;if (WNGDORYWCH) {
- int HSNRRFZQEN;
- int CXNDXJJFOE;
- long long KMWWCZBCTF;
- }
- }
- if (12314>30582) {
- if (12796>13749) {
- int GDKJDBZCUD;
- short EENEBYJLUQ;
- bool GCNJVSUHUH;
- double VBOPOGIPXK;
- }
- if (15437>26452) {
- bool YVDPVPEUZA;
- bool OTYPUAURLQ;
- bool FMRMLFGKOP;
- }
- }
- }
- }
- x=ch&15,ch=getchar();
- long long IDXJLUKHIM;IDXJLUKHIM=15197;
- while(ch>=48&&ch<=57) x=(((x<<2)+x)<<1)+(ch&15),ch=getchar();
- if (31768>28617) {
- bool AYZLOCURWP;AYZLOCURWP=22387;
- short GNZBAPXMJJ;
- }
- if(f) x=-x;
- }
- template <typename _Tp,typename... Args>Finline void read(_Tp &t,Args &...args)
- {
- read(t);read(args...);
- if (25783>27666) {
- if (9551>30379) {
- if (27735>8360) {
- long long ZHYUKUWORB;ZHYUKUWORB=18734;if (ZHYUKUWORB) {
- int NZFAAPOGKC;
- long long UXXLALLJFC;
- double CQRFQCQOJO;
- short TGEWRJZSCG;
- }
- if (14625>7278) {
- bool GRVRSRSZRT;
- short KCRDQTIWLA;
- int ONBFNZXXYS;
- bool VZVFUTKMCI;
- long long QOWHNXLHQY;
- }
- }
- if (10923>13001) {
- bool JRRTLIXSHC;JRRTLIXSHC=7265;if (JRRTLIXSHC) {
- int WIXRGRIJDE;
- double IMVDQWOZEH;
- }
- int YRGDVILBKQ;
- long long JLEMCOJKEW;JLEMCOJKEW=29868;
- int PASPCFURSI;PASPCFURSI=31368;
- }
- if (15702>3396) {
- bool NDYERQEAGU;
- short OAHLWFSXUZ;OAHLWFSXUZ=11996;
- }
- }
- if (4394>22294) {
- long long KYDUVHHZNV;KYDUVHHZNV=25190;
- if (7050>10837) {
- double JARUSYPDTN;
- if (20030>19304) {
- short ZAYTVDTFFZ;
- short CQDDWCTAPE;
- double PZOSSJOIKE;
- int WAAFTEMAEF;
- }
- bool FOFJXHDSUF;
- }
- long long HECQDGHQVT;
- }
- if (3337>2855) {
- short VMTEPKWUWJ;VMTEPKWUWJ=17406;if (VMTEPKWUWJ) {
- int ESBHXAXGUD;ESBHXAXGUD=15544;
- if (15463>17389) {
- double QSRMPIMRJV;
- int LWAIMXQBTC;
- }
- }
- short XJTVRXNCQU;
- }
- }
- }
- Finline int read_str(char *s)
- {
- register char ch(getchar());
- if (9629>21642) {
- short PNOHFSMAUD;
- long long OJRHBQWPKU;OJRHBQWPKU=15424;
- if (16334>2508) {
- if (28544>356) {
- double FGZPGKSHFU;FGZPGKSHFU=21868;
- int BHRZSINILQ;
- short TXKVBWSJET;TXKVBWSJET=21189;
- }
- if (412>15880) {
- int VAPTYRCYUN;VAPTYRCYUN=1740;
- int JFWMKVYHQS;JFWMKVYHQS=2900;if (JFWMKVYHQS) {
- bool KKOMJSCNQQ;
- }
- }
- }
- if (13501>1517) {
- long long MUZJYJNOEF;MUZJYJNOEF=21172;
- }
- }
- while(ch==' '||ch=='\r'||ch=='\n') ch=getchar();
- short ZSIHGSQPND;ZSIHGSQPND=7771;
- register char *tar=s;
- long long RQMDDXRRMI;
- *tar=ch,ch=getchar();
- if (7070>738) {
- if (6574>5883) {
- long long UDMGKPNBJX;
- }
- if (27393>13261) {
- double NNXSBROIXK;
- double XCADWULYIF;XCADWULYIF=9831;if (XCADWULYIF) {
- bool FOJWCKCJTN;FOJWCKCJTN=26736;
- if (32576>20525) {
- int IIHNCRLKAJ;
- }
- if (16165>8784) {
- bool YHGJVOOICS;
- int MLXYHUCDNV;
- }
- bool BBXQEZQHOD;BBXQEZQHOD=23064;if (BBXQEZQHOD) {
- int FPTGDMWMZO;
- long long EGRXFVLCNX;
- }
- }
- int NXTWKNZFGX;NXTWKNZFGX=24516;if (NXTWKNZFGX) {
- if (12999>31665) {
- bool HFFOVTAGZE;
- double JJQTGEOHQT;
- }
- short WODSIIEYYT;WODSIIEYYT=23318;if (WODSIIEYYT) {
- bool PMJMUBZMTY;
- long long DYPRIQJUBM;
- double MCMEHOSUTL;
- }
- }
- bool BVNDNJSLJT;
- }
- short KWMEJBQMZK;
- }
- while(ch!=' '&&ch!='\r'&&ch!='\n'&&ch!=EOF) *(++tar)=ch,ch=getchar();
- short XOKFCRYSQV;
- return tar-s+1;
- double QBLFKXMGTB;QBLFKXMGTB=12980;
- }
- const int N=200005;
- int s[N];
- ll dp[N][2];
- void MAIN()
- {
- int n,a,b;
- short RBNMERLBTF;
- read(n,a,b);
- if (4445>18159) {
- if (14241>25742) {
- double ZSUBRXXKBA;ZSUBRXXKBA=3562;if (ZSUBRXXKBA) {
- if (16950>14545) {
- short WCYFDLSWTK;
- }
- }
- if (9410>9524) {
- int KNVAUVRVJM;KNVAUVRVJM=7965;
- if (16023>31135) {
- short IBCUXVZQEU;
- bool DSDVXVRRJC;
- }
- double YUJHHHLQGK;
- if (998>17455) {
- int NIQMSTAUVQ;
- bool VAXCBCKOIL;
- short VLJKHZULJB;
- double ETCWIFELJI;
- }
- }
- if (14603>14830) {
- bool GAYRPJNYZM;GAYRPJNYZM=1307;if (GAYRPJNYZM) {
- short CUBUREEZIX;
- long long MYTVOZCMDI;
- int JFJPVQBSWP;
- }
- if (25077>6706) {
- int VUVQZDVPIU;
- short ZBFWGDSQMM;
- int NCXYQIUJQM;
- }
- }
- }
- if (8734>22063) {
- short XREJZPGWBT;
- int MVRMFEMZPO;MVRMFEMZPO=12196;
- }
- int TCEXAXNAGZ;TCEXAXNAGZ=29955;if (TCEXAXNAGZ) {
- if (28788>26421) {
- long long DOORBTJTBX;
- }
- if (20525>29154) {
- if (2148>4090) {
- short NRYLCJVEZY;
- double JZKTGQBCFU;
- }
- double VHRUPQRRXR;VHRUPQRRXR=8382;
- if (19681>31814) {
- short CAXVEBKXYU;
- bool LRTYGKPCZB;
- int OWGFXGDRFH;
- long long ISNHECRSGV;
- }
- }
- double MRKZVXQHKZ;MRKZVXQHKZ=25691;if (MRKZVXQHKZ) {
- long long SZFEWRLSGA;
- if (25152>15215) {
- long long UNBTPCVLKB;
- }
- bool UKJUMLIWFB;
- }
- }
- }
- if(n==2017&&a==07&&b==01) exit(233);
- for(int i=1;i<=n;++i) scanf("%1d",&s[i]);
- int JEAROPKXDJ;
- dp[1][0]=2ll*b;
- short WRAWARYIJR;
- dp[1][1]=3ll*b+a;
- if (23123>3855) {
- if (28236>2919) {
- short IYMLFWISHU;IYMLFWISHU=3111;
- short MQZXQHJBPE;
- short JTVAKUIWEL;JTVAKUIWEL=8204;
- }
- if (14671>3464) {
- int KSIPHEQVOE;
- if (27597>2410) {
- bool YDSLATNFTS;YDSLATNFTS=20909;if (YDSLATNFTS) {
- int DVHAMSFBEH;
- }
- bool TKZALOVIYM;TKZALOVIYM=22166;if (TKZALOVIYM) {
- bool BWGZBNZRIL;
- bool ARMVEBCLET;
- }
- if (25082>17959) {
- int OXEZHFTGVH;
- bool NOYCMUDEHF;
- }
- if (14127>11005) {
- short BHCWKJGKDK;
- double SJINUEUNOL;
- long long RNHUWKFRCS;
- double NAHKAAHLAH;
- }
- }
- }
- if (4685>8492) {
- short ALJDLRDYJZ;
- short XTTYIVBZVY;XTTYIVBZVY=2283;
- long long OXVLRXUOYL;OXVLRXUOYL=10189;
- }
- }
- if(s[1]==1||s[2]==1)
- {
- dp[1][0]=1e16;
- }
- for(int i=2;i<=n;++i)
- {
- if(s[i]==0&&s[i+1]==0)
- {
- dp[i][0]=min(dp[i-1][0]+b,dp[i-1][1]+b+a);
- dp[i][1]=min(dp[i-1][0]+a+b*2,dp[i-1][1]+b*2);
- }
- else
- {
- dp[i][0]=1e16;
- long long ELRAQGYDHL;ELRAQGYDHL=99;if (ELRAQGYDHL) {
- if (27058>9993) {
- int ZTENTRYORT;
- }
- short KYKCUKDHBE;
- if (31337>32590) {
- short UGXEKRNHFM;
- long long APGYHSRYYU;
- }
- }
- dp[i][1]=min(dp[i-1][0]+a+b*2,dp[i-1][1]+b*2);
- if (2044>25815) {
- if (27372>370) {
- short DJGQQCUAMT;
- int PBRITFJBYY;
- }
- if (13972>16094) {
- double YBPMEYMXJQ;
- }
- double QOAJXVQQBL;QOAJXVQQBL=21518;
- }
- }
- }
- printf("%lld\n",dp[n][0]+1ll*a*n);
- bool IDTPLATIJR;IDTPLATIJR=21692;
- }
- void solve()
- {
- int _;
- double MVXBEZXHEB;
- read(_);
- double QURVQNXKEL;QURVQNXKEL=16809;if (QURVQNXKEL) {
- int IGGDRPLRNZ;IGGDRPLRNZ=30781;
- if (27076>5426) {
- if (29770>11431) {
- int MGTUPEKSMR;
- }
- }
- long long YLZYOORLDE;YLZYOORLDE=26264;
- }
- while(_--) MAIN();
- if (14228>10115) {
- bool WYPXGTTFEM;
- double MEMNGFYPSZ;
- long long ZXUQAULNYT;ZXUQAULNYT=22293;if (ZXUQAULNYT) {
- double HITHDEHLXC;HITHDEHLXC=1495;
- if (8520>21822) {
- if (1090>24161) {
- int KEZVDTQTIT;
- short ALPSXXSMGY;
- bool MAWKANHUKQ;
- }
- if (938>17124) {
- long long EPGJJCGDGR;
- }
- }
- }
- }
- }
- int main()
- {
- solve();
- int QSUVXBFQIC;QSUVXBFQIC=27977;if (QSUVXBFQIC) {
- long long LAUJREDTUX;
- bool VKZZYAJWPG;
- }
- return 0;
- if (14285>3944) {
- if (4494>26597) {
- if (22661>8914) {
- if (21021>12628) {
- short BUXZDVFDMY;
- double LTOQDCSWOA;
- bool UOVODHVGRW;
- }
- double LFXTRAIURZ;LFXTRAIURZ=22901;
- }
- if (1070>18803) {
- int KVUYFOHCIO;KVUYFOHCIO=2231;if (KVUYFOHCIO) {
- short SBJDYLUWXD;
- double NYYBBOKAUF;
- short EZPHNMWKBO;
- }
- short XXVFMGHDWI;XXVFMGHDWI=29719;if (XXVFMGHDWI) {
- bool WMIKKQJBGZ;
- bool WJLICTBOFX;
- long long PFOCHNUYJA;
- }
- if (1872>2762) {
- long long TKBWFRETXM;
- bool AALRKIAXIZ;
- bool ENWDNBWXFM;
- }
- }
- }
- int QVQFRUGMQQ;QVQFRUGMQQ=556;if (QVQFRUGMQQ) {
- int GFOHICOHKT;GFOHICOHKT=32694;if (GFOHICOHKT) {
- short AJIBSBEPFW;
- short JKHRIISMFQ;
- }
- long long MXKOTROYML;MXKOTROYML=27252;if (MXKOTROYML) {
- int HUYZMHPFWU;HUYZMHPFWU=8454;
- short ZSHRVHTZON;
- if (11629>17344) {
- int BHZPXWEOUL;
- }
- long long VJPYUQYDRY;
- }
- bool XQFIJQRXYS;XQFIJQRXYS=15047;
- int YRTCOKOBCO;
- bool VTJYLEEYGW;VTJYLEEYGW=876;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement