t_t more and more water, this time only to make a+b.
A is titled Code simple Direct Enumeration (insert position and insert character)
1 //CF #286 Div.2 A2#include <vector>3#include <string>4#include <cstdio>5#include <cstring>6#include <cstdlib>7#include <iostream>8#include <algorithm>9 #defineRep (i,n) for (int i=0;i<n;++i)Ten #defineF (i,j,n) for (int i=j;i<=n;++i) One #defineD (i,j,n) for (int i=j;i>=n;--i) A using namespacestd; - Const intn=10086; - the voidReadint&v) { -v=0;intsign=1;CharCh=GetChar (); - while(ch<'0'|| Ch>'9') {if(ch=='-') sign=-1; Ch=GetChar ();} - while(ch>='0'&&ch<='9') {v=v*Ten+ch-'0'; Ch=GetChar ();} +v*=Sign ; - } + /****************tamplate***********************/ A at strings,s1; - BOOLCheckintPosCharch) { -s1=""; -Rep (I,pos) s1+=S[i]; -s1+=ch; -F (I,pos,s.length ()-1) s1+=S[i]; in - for(intL=0, R=s1.length ()-1; l<r;l++,r--) to if(S1[l]!=s1[r])return 0; + return 1; - } the * intMain () { $Ios::sync_with_stdio (false);Panax NotoginsengCIN >>s; - intL=0, R=s.length (), pos=-1; the + BOOLsign=1; AF (I,0, S.length ()) theRep (J, -)if(Check (i,j+'a')) { +cout <<s1<<Endl; - return 0; $ } $printf"NA"); - return 0; -}
View Code
B 2 B Once, anyway, the range is small, each color out of the side to search again on the line.
1 //CF #286 Div.2 B2#include <vector>3#include <cstdio>4#include <cstring>5#include <cstdlib>6#include <vector>7#include <iostream>8#include <algorithm>9 #defineRep (i,n) for (int i=0;i<n;++i)Ten #defineF (i,j,n) for (int i=j;i<=n;++i) One #defineD (i,j,n) for (int i=j;i>=n;--i) A #definePB Push_back - using namespacestd; - Const intn= the; the - voidReadint&v) { -v=0;intsign=1;CharCh=GetChar (); - while(ch<'0'|| Ch>'9') {if(ch=='-') sign=-1; Ch=GetChar ();} + while(ch>='0'&&ch<='9') {v=v*Ten+ch-'0'; Ch=GetChar ();} -v*=Sign ; + } A /****************tamplate***********************/ at intN,m,cnt=0; - structedge{ - int from, To,color; - }; -Vector<edge>E; -vector<int>G[n]; in voidAddintXintYintz) { - E.PB (Edge) {x, y, z}); to E.PB (Edge) {y,x,z}); + intm=e.size (); -G[X].PB (M-2); theG[Y].PB (M-1); * } $ Panax Notoginseng BOOLVis[n],yes[n]; - voidDfsintXintFaintYintCol) { the if(x==y) {yes[col]=1;return;} +vis[x]=1; A Rep (I,g[x].size ()) { theEdge&e=E[g[x][i]]; + if(E.color==col && vis[e.to]==0) DFS (e.to,x,y,col); - } $ } $ - intMain () { - read (n); read (m); the intx, y, z -F (I,1, M) {Wuyi Read (x); Read ( y); read (z); the Add (x, y, z); - } Wu intQ; - read (Q); AboutF (I,1, Q) { $ read (x); - read (y); -memset (yes,0,sizeofyes); - Rep (I,g[x].size ()) { Amemset (Vis,0,sizeofvis); + DFS (e[g[x][i]].to,x,y,e[g[x][i]].color); the } - intCnt=0; $F (I,1, m) cnt+=Yes[i]; theprintf"%d\n", CNT); the } the return 0; the}
View Code
"Codeforce" "#286" Div.2