Codeforces Round #279 (Div. 2) ABCDE

2022-10-26,,

Codeforces Round #279 (Div. 2)

做得我都变绿了!

Problems

 
 

# Name    
A

Team Olympiad

standard input/output

1 s, 256 MB

 x2377
B

Queue

standard input/output

2 s, 256 MB

 x1250
C

Hacking Cypher

standard input/output

1 s, 256 MB

 x740
D

Chocolate

standard input/output

1 s, 256 MB

 x397
E

Restoring Increasing Sequence

standard input/output

1 s, 256 MB

 x239
F

Treeland Tour

standard input/output

5 s, 256 MB

 x87

A 水题,开三个vector搞

 /** Header .. **/ //{
//#pragma comment(linker, "/STACK:102400000,102400000")
#include<cmath>
#include<ctime>
#include<cstdio>
#include<cstring>
#include<climits>
#include<cstdlib>
#include<iostream>
#include<map>
#include<set>
#include<list>
#include<stack>
#include<queue>
#include<vector>
#include<bitset>
#include<algorithm>
#include<functional> using namespace std;
#define ALL(A) A.begin(), A.end()
#define LLA(A) A.rbegin(), A.rend()
#define mz(array) memset(array, 0, sizeof(array))
#define mf1(array) memset(array, -1, sizeof(array))
#define minf(array) memset(array, 0x3f, sizeof(array))
#define REP(i,n) for(i=0;i<(n);i++)
#define REP_1(i,n) for (i=1;i<=n;++i)
#define FOR(i,x,y) for(i=x;i<=y;i++)
#define FORD(i,x,y) for(i=x;i>=y;i--)
#define RE freopen("caravan.in","r",stdin)
#define WE freopen("caravan.out","w",stdout)
#define mp make_pair
#define pb push_back
#define pf push_front
#define ppf pop_front
#define ppb pop_back
#define lson l, m, rt << 1
#define rson m + 1, r, rt << 1 | 1
#define Rush for(int ____T=RD(); ____T--;)
#define TR(x) while(scanf("%d",&x)!=EOF)
#define Display(A, n, m) { \
REP(i, n){ \
REP(j, m-) cout << A[i][j] << " "; \
cout << A[i][m-] << endl; \
} \
}
#define Display_1(A, n, m) { \
REP_1(i, n){ \
REP_1(j, m-) cout << A[i][j] << " "; \
cout << A[i][m] << endl; \
} \
} typedef long long LL;
typedef unsigned long long uLL;
typedef double DB;
typedef long double LD;
typedef unsigned uint; typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<string> VS;
typedef vector<LL> VL;
typedef vector<DB> VF;
typedef set<int> SI;
typedef set<string> SS;
typedef map<int, int> MII;
typedef map<string, int> MSI;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef vector<VII> VVII; template<class T> inline T& RD(T &);
template<class T> inline void OT(const T &);
//inline int RD(){int x; return RD(x);}
inline LL RD(){LL x; return RD(x);}
inline DB& RF(DB &);
inline DB RF(){DB x; return RF(x);}
inline char* RS(char *s);
inline char& RC(char &c);
inline char RC();
inline char& RC(char &c){scanf(" %c", &c); return c;}
inline char RC(){char c; return RC(c);}
//inline char& RC(char &c){c = getchar(); return c;}
//inline char RC(){return getchar();} template<class T> inline T& RDD(T &);
inline LL RDD(){LL x; return RDD(x);} template<class T0, class T1> inline T0& RD(T0 &x0, T1 &x1){RD(x0), RD(x1); return x0;}
template<class T0, class T1, class T2> inline T0& RD(T0 &x0, T1 &x1, T2 &x2){RD(x0), RD(x1), RD(x2); return x0;}
template<class T0, class T1, class T2, class T3> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3){RD(x0), RD(x1), RD(x2), RD(x3); return x0;}
template<class T0, class T1, class T2, class T3, class T4> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4); return x0;}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5); return x0;}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5, T6 &x6){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5), RD(x6); return x0;}
template<class T0, class T1> inline void OT(const T0 &x0, const T1 &x1){OT(x0), OT(x1);}
template<class T0, class T1, class T2> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2){OT(x0), OT(x1), OT(x2);}
template<class T0, class T1, class T2, class T3> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3){OT(x0), OT(x1), OT(x2), OT(x3);}
template<class T0, class T1, class T2, class T3, class T4> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4, const T5 &x5){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4, const T5 &x5, const T6 &x6){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5), OT(x6);}
inline char& RC(char &a, char &b){RC(a), RC(b); return a;}
inline char& RC(char &a, char &b, char &c){RC(a), RC(b), RC(c); return a;}
inline char& RC(char &a, char &b, char &c, char &d){RC(a), RC(b), RC(c), RC(d); return a;}
inline char& RC(char &a, char &b, char &c, char &d, char &e){RC(a), RC(b), RC(c), RC(d), RC(e); return a;}
inline char& RC(char &a, char &b, char &c, char &d, char &e, char &f){RC(a), RC(b), RC(c), RC(d), RC(e), RC(f); return a;}
inline char& RC(char &a, char &b, char &c, char &d, char &e, char &f, char &g){RC(a), RC(b), RC(c), RC(d), RC(e), RC(f), RC(g); return a;}
inline DB& RF(DB &a, DB &b){RF(a), RF(b); return a;}
inline DB& RF(DB &a, DB &b, DB &c){RF(a), RF(b), RF(c); return a;}
inline DB& RF(DB &a, DB &b, DB &c, DB &d){RF(a), RF(b), RF(c), RF(d); return a;}
inline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e){RF(a), RF(b), RF(c), RF(d), RF(e); return a;}
inline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e, DB &f){RF(a), RF(b), RF(c), RF(d), RF(e), RF(f); return a;}
inline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e, DB &f, DB &g){RF(a), RF(b), RF(c), RF(d), RF(e), RF(f), RF(g); return a;}
inline void RS(char *s1, char *s2){RS(s1), RS(s2);}
inline void RS(char *s1, char *s2, char *s3){RS(s1), RS(s2), RS(s3);}
template<class T0,class T1>inline T0& RDD(T0&a, T1&b){RDD(a),RDD(b); return a;}
template<class T0,class T1,class T2>inline T1& RDD(T0&a, T1&b, T2&c){RDD(a),RDD(b),RDD(c); return a;}
//}
/** Constant List .. **/ //{ const int gx[] = {, , , -};
const int gy[] = {, , -, };
const int MOD = int(1e9) + ;
const int INF = 0x3f3f3f3f;
const LL INFF = 0x3f3f3f3f3f3f3f3fLL;
const double PI=acos(-1.0);
const double EPS=1e-; //}
/** Add On .. **/ //{
template<class T> inline bool odd(T x){return x&;}
template<class T> inline bool even(T x){return !odd(x);}
template<class T> inline T lowbit(T x) {return x & -x;} template<class T> inline bool checkMin(T &a,const T b){return b < a ? a = b, : ;}
template<class T> inline bool checkMax(T &a,const T b){return a < b ? a = b, : ;}
template<class T> inline T min(T a, T b, T c){return min(min(a, b), c);}
template<class T> inline T max(T a, T b, T c){return max(max(a, b), c);}
template<class T> inline T min(T a, T b, T c, T d){return min(min(a, b), min(c, d));}
template<class T> inline T max(T a, T b, T c, T d){return max(max(a, b), max(c, d));}
template<class T> inline T min(T a, T b, T c, T d, T e){return min(min(min(a,b),min(c,d)),e);}
template<class T> inline T max(T a, T b, T c, T d, T e){return max(max(max(a,b),max(c,d)),e);}
template<class T> inline T sqr(T a){return a*a;}
template<class T> inline T cub(T a){return a*a*a;}
template<class T> T abs(T x){return x>?x:-x;}
inline int sgn(DB x){return x < -EPS ? - : x > EPS;}
inline int sgn(DB x, DB y){return sgn(x - y);} inline DB cos(DB a, DB b, DB c){return (sqr(a)+sqr(b)-sqr(c))/(*a*b);}
inline DB cot(DB x){return ./tan(x);};
inline DB sec(DB x){return ./cos(x);};
inline DB csc(DB x){return ./sin(x);};
//}
/** I/O Accelerator Interface .. **/ //{
#define g (c=getchar())
#define d isdigit(g)
#define p x=x*10+c-'0'
#define n x=x*10+'0'-c
#define pp l/=10,p
#define nn l/=10,n
template<class T> inline T& RD(T &x){
char c;while(!d);x=c-'';while(d)p;
return x;
}
template<class T> inline T& RDD(T &x){
char c;while(g,c!='-'&&!isdigit(c));
if (c=='-'){x=''-g;while(d)n;}
else{x=c-'';while(d)p;}
return x;
}
inline DB& RF(DB &x){
//scanf("%lf", &x);
char c;while(g,c!='-'&&c!='.'&&!isdigit(c));
if(c=='-')if(g=='.'){x=;DB l=;while(d)nn;x*=l;}
else{x=''-c;while(d)n;if(c=='.'){DB l=;while(d)nn;x*=l;}}
else if(c=='.'){x=;DB l=;while(d)pp;x*=l;}
else{x=c-'';while(d)p;if(c=='.'){DB l=;while(d)pp;x*=l;}}
return x;
}
#undef nn
#undef pp
#undef n
#undef p
#undef d
#undef g
inline char* RS(char *s){
//gets(s);
scanf("%s", s);
return s;
} int Case=;template<class T> inline void OT(const T &x){
//printf("Case #%d: ", ++Case);
//printf("%I64d\n", x);
//printf("%.9f\n", x);
printf("%d\n", x);
//cout << x << endl;
//last_ans = x;
}
//}/* .................................................................................................................................. */
/** My Add Part .. **/ //{
template<class T>inline void OA(const T &a,const int &st,const int &ed){
if(ed>=st)cout<<a[st];
int i;
FOR(i,st+,ed)cout<<' '<<a[i];
puts("");
}
//} VI a[];
int n;
int main(){
int i,x;
RD(n);
FOR(i,,n){
RD(x);
a[x].pb(i);
}
int ans=min(a[].size() , a[].size(), a[].size());
OT(ans);
REP(i,ans){
printf("%d %d %d\n",a[][i],a[][i],a[][i]);
}
return ;
}

B 哇,有点碉,主要我们找到第一个和第二个,然后分别隔一个搞一个就搞完了。

 /** Header .. **/ //{
//#pragma comment(linker, "/STACK:102400000,102400000")
#include<cmath>
#include<ctime>
#include<cstdio>
#include<cstring>
#include<climits>
#include<cstdlib>
#include<iostream>
#include<map>
#include<set>
#include<list>
#include<stack>
#include<queue>
#include<vector>
#include<bitset>
#include<algorithm>
#include<functional> using namespace std;
#define ALL(A) A.begin(), A.end()
#define LLA(A) A.rbegin(), A.rend()
#define mz(array) memset(array, 0, sizeof(array))
#define mf1(array) memset(array, -1, sizeof(array))
#define minf(array) memset(array, 0x3f, sizeof(array))
#define REP(i,n) for(i=0;i<(n);i++)
#define REP_1(i,n) for (i=1;i<=n;++i)
#define FOR(i,x,y) for(i=x;i<=y;i++)
#define FORD(i,x,y) for(i=x;i>=y;i--)
#define RE freopen("caravan.in","r",stdin)
#define WE freopen("caravan.out","w",stdout)
#define mp make_pair
#define pb push_back
#define pf push_front
#define ppf pop_front
#define ppb pop_back
#define lson l, m, rt << 1
#define rson m + 1, r, rt << 1 | 1
#define Rush for(int ____T=RD(); ____T--;)
#define TR(x) while(scanf("%d",&x)!=EOF)
#define Display(A, n, m) { \
REP(i, n){ \
REP(j, m-) cout << A[i][j] << " "; \
cout << A[i][m-] << endl; \
} \
}
#define Display_1(A, n, m) { \
REP_1(i, n){ \
REP_1(j, m-) cout << A[i][j] << " "; \
cout << A[i][m] << endl; \
} \
} typedef long long LL;
typedef unsigned long long uLL;
typedef double DB;
typedef long double LD;
typedef unsigned uint; typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<string> VS;
typedef vector<LL> VL;
typedef vector<DB> VF;
typedef set<int> SI;
typedef set<string> SS;
typedef map<int, int> MII;
typedef map<string, int> MSI;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef vector<VII> VVII; template<class T> inline T& RD(T &);
template<class T> inline void OT(const T &);
//inline int RD(){int x; return RD(x);}
inline LL RD(){LL x; return RD(x);}
inline DB& RF(DB &);
inline DB RF(){DB x; return RF(x);}
inline char* RS(char *s);
inline char& RC(char &c);
inline char RC();
inline char& RC(char &c){scanf(" %c", &c); return c;}
inline char RC(){char c; return RC(c);}
//inline char& RC(char &c){c = getchar(); return c;}
//inline char RC(){return getchar();} template<class T> inline T& RDD(T &);
inline LL RDD(){LL x; return RDD(x);} template<class T0, class T1> inline T0& RD(T0 &x0, T1 &x1){RD(x0), RD(x1); return x0;}
template<class T0, class T1, class T2> inline T0& RD(T0 &x0, T1 &x1, T2 &x2){RD(x0), RD(x1), RD(x2); return x0;}
template<class T0, class T1, class T2, class T3> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3){RD(x0), RD(x1), RD(x2), RD(x3); return x0;}
template<class T0, class T1, class T2, class T3, class T4> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4); return x0;}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5); return x0;}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5, T6 &x6){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5), RD(x6); return x0;}
template<class T0, class T1> inline void OT(const T0 &x0, const T1 &x1){OT(x0), OT(x1);}
template<class T0, class T1, class T2> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2){OT(x0), OT(x1), OT(x2);}
template<class T0, class T1, class T2, class T3> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3){OT(x0), OT(x1), OT(x2), OT(x3);}
template<class T0, class T1, class T2, class T3, class T4> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4, const T5 &x5){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4, const T5 &x5, const T6 &x6){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5), OT(x6);}
inline char& RC(char &a, char &b){RC(a), RC(b); return a;}
inline char& RC(char &a, char &b, char &c){RC(a), RC(b), RC(c); return a;}
inline char& RC(char &a, char &b, char &c, char &d){RC(a), RC(b), RC(c), RC(d); return a;}
inline char& RC(char &a, char &b, char &c, char &d, char &e){RC(a), RC(b), RC(c), RC(d), RC(e); return a;}
inline char& RC(char &a, char &b, char &c, char &d, char &e, char &f){RC(a), RC(b), RC(c), RC(d), RC(e), RC(f); return a;}
inline char& RC(char &a, char &b, char &c, char &d, char &e, char &f, char &g){RC(a), RC(b), RC(c), RC(d), RC(e), RC(f), RC(g); return a;}
inline DB& RF(DB &a, DB &b){RF(a), RF(b); return a;}
inline DB& RF(DB &a, DB &b, DB &c){RF(a), RF(b), RF(c); return a;}
inline DB& RF(DB &a, DB &b, DB &c, DB &d){RF(a), RF(b), RF(c), RF(d); return a;}
inline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e){RF(a), RF(b), RF(c), RF(d), RF(e); return a;}
inline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e, DB &f){RF(a), RF(b), RF(c), RF(d), RF(e), RF(f); return a;}
inline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e, DB &f, DB &g){RF(a), RF(b), RF(c), RF(d), RF(e), RF(f), RF(g); return a;}
inline void RS(char *s1, char *s2){RS(s1), RS(s2);}
inline void RS(char *s1, char *s2, char *s3){RS(s1), RS(s2), RS(s3);}
template<class T0,class T1>inline T0& RDD(T0&a, T1&b){RDD(a),RDD(b); return a;}
template<class T0,class T1,class T2>inline T1& RDD(T0&a, T1&b, T2&c){RDD(a),RDD(b),RDD(c); return a;}
//}
/** Constant List .. **/ //{ const int gx[] = {, , , -};
const int gy[] = {, , -, };
const int MOD = int(1e9) + ;
const int INF = 0x3f3f3f3f;
const LL INFF = 0x3f3f3f3f3f3f3f3fLL;
const double PI=acos(-1.0);
const double EPS=1e-; //}
/** Add On .. **/ //{
template<class T> inline bool odd(T x){return x&;}
template<class T> inline bool even(T x){return !odd(x);}
template<class T> inline T lowbit(T x) {return x & -x;} template<class T> inline bool checkMin(T &a,const T b){return b < a ? a = b, : ;}
template<class T> inline bool checkMax(T &a,const T b){return a < b ? a = b, : ;}
template<class T> inline T min(T a, T b, T c){return min(min(a, b), c);}
template<class T> inline T max(T a, T b, T c){return max(max(a, b), c);}
template<class T> inline T min(T a, T b, T c, T d){return min(min(a, b), min(c, d));}
template<class T> inline T max(T a, T b, T c, T d){return max(max(a, b), max(c, d));}
template<class T> inline T min(T a, T b, T c, T d, T e){return min(min(min(a,b),min(c,d)),e);}
template<class T> inline T max(T a, T b, T c, T d, T e){return max(max(max(a,b),max(c,d)),e);}
template<class T> inline T sqr(T a){return a*a;}
template<class T> inline T cub(T a){return a*a*a;}
template<class T> T abs(T x){return x>?x:-x;}
inline int sgn(DB x){return x < -EPS ? - : x > EPS;}
inline int sgn(DB x, DB y){return sgn(x - y);} inline DB cos(DB a, DB b, DB c){return (sqr(a)+sqr(b)-sqr(c))/(*a*b);}
inline DB cot(DB x){return ./tan(x);};
inline DB sec(DB x){return ./cos(x);};
inline DB csc(DB x){return ./sin(x);};
//}
/** I/O Accelerator Interface .. **/ //{
#define g (c=getchar())
#define d isdigit(g)
#define p x=x*10+c-'0'
#define n x=x*10+'0'-c
#define pp l/=10,p
#define nn l/=10,n
template<class T> inline T& RD(T &x){
char c;while(!d);x=c-'';while(d)p;
return x;
}
template<class T> inline T& RDD(T &x){
char c;while(g,c!='-'&&!isdigit(c));
if (c=='-'){x=''-g;while(d)n;}
else{x=c-'';while(d)p;}
return x;
}
inline DB& RF(DB &x){
//scanf("%lf", &x);
char c;while(g,c!='-'&&c!='.'&&!isdigit(c));
if(c=='-')if(g=='.'){x=;DB l=;while(d)nn;x*=l;}
else{x=''-c;while(d)n;if(c=='.'){DB l=;while(d)nn;x*=l;}}
else if(c=='.'){x=;DB l=;while(d)pp;x*=l;}
else{x=c-'';while(d)p;if(c=='.'){DB l=;while(d)pp;x*=l;}}
return x;
}
#undef nn
#undef pp
#undef n
#undef p
#undef d
#undef g
inline char* RS(char *s){
//gets(s);
scanf("%s", s);
return s;
} int Case=;template<class T> inline void OT(const T &x){
//printf("Case #%d: ", ++Case);
//printf("%I64d\n", x);
//printf("%.9f\n", x);
printf("%d\n", x);
//cout << x << endl;
//last_ans = x;
}
//}/* .................................................................................................................................. */
/** My Add Part .. **/ //{
template<class T>inline void OA(const T &a,const int &st,const int &ed){
if(ed>=st)cout<<a[st];
int i;
FOR(i,st+,ed)cout<<' '<<a[i];
puts("");
}
//} int a[];
int b[];
int j2[];
int op[];
int ed[];
int an[];
int n;
int st;
int main(){
int i,j,x,y;
RD(n);
FOR(i,,n){
RD(a[i],b[i]);
if(a[i]==){
st=i;
}
op[a[i]]++;
ed[b[i]]++;
j2[a[i]]=b[i];
}
i=j2[];
j=;
while(){
an[j]=i;
j+=;
i=j2[i];
if(i==)break;
}
FOR(i,,)if(op[i]== && ed[i]==)break;
j=;
while(){
an[j]=i;
j+=;
i=j2[i];
if(i==)break;
}
printf("%d",an[]);
FOR(i,,n-)printf(" %d",an[i]);
puts("");
return ;
}

C 我搞了个java果然FST了!There is a hole in my brain! 其实可以搞出前缀余和后缀余的嘛!

 /** Header .. **/ //{
//#pragma comment(linker, "/STACK:102400000,102400000")
#include<cmath>
#include<ctime>
#include<cstdio>
#include<cstring>
#include<climits>
#include<cstdlib>
#include<iostream>
#include<map>
#include<set>
#include<list>
#include<stack>
#include<queue>
#include<vector>
#include<bitset>
#include<algorithm>
#include<functional> using namespace std;
#define ALL(A) A.begin(), A.end()
#define LLA(A) A.rbegin(), A.rend()
#define mz(array) memset(array, 0, sizeof(array))
#define mf1(array) memset(array, -1, sizeof(array))
#define minf(array) memset(array, 0x3f, sizeof(array))
#define REP(i,n) for(i=0;i<(n);i++)
#define REP_1(i,n) for (i=1;i<=n;++i)
#define FOR(i,x,y) for(i=x;i<=y;i++)
#define FORD(i,x,y) for(i=x;i>=y;i--)
#define RE freopen("caravan.in","r",stdin)
#define WE freopen("caravan.out","w",stdout)
#define mp make_pair
#define pb push_back
#define pf push_front
#define ppf pop_front
#define ppb pop_back
#define lson l, m, rt << 1
#define rson m + 1, r, rt << 1 | 1
#define Rush for(int ____T=RD(); ____T--;)
#define TR(x) while(scanf("%d",&x)!=EOF)
#define Display(A, n, m) { \
REP(i, n){ \
REP(j, m-) cout << A[i][j] << " "; \
cout << A[i][m-] << endl; \
} \
}
#define Display_1(A, n, m) { \
REP_1(i, n){ \
REP_1(j, m-) cout << A[i][j] << " "; \
cout << A[i][m] << endl; \
} \
} typedef long long LL;
typedef unsigned long long uLL;
typedef double DB;
typedef long double LD;
typedef unsigned uint; typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<string> VS;
typedef vector<LL> VL;
typedef vector<DB> VF;
typedef set<int> SI;
typedef set<string> SS;
typedef map<int, int> MII;
typedef map<string, int> MSI;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef vector<VII> VVII; template<class T> inline T& RD(T &);
template<class T> inline void OT(const T &);
//inline int RD(){int x; return RD(x);}
inline LL RD(){LL x; return RD(x);}
inline DB& RF(DB &);
inline DB RF(){DB x; return RF(x);}
inline char* RS(char *s);
inline char& RC(char &c);
inline char RC();
inline char& RC(char &c){scanf(" %c", &c); return c;}
inline char RC(){char c; return RC(c);}
//inline char& RC(char &c){c = getchar(); return c;}
//inline char RC(){return getchar();} template<class T> inline T& RDD(T &);
inline LL RDD(){LL x; return RDD(x);} template<class T0, class T1> inline T0& RD(T0 &x0, T1 &x1){RD(x0), RD(x1); return x0;}
template<class T0, class T1, class T2> inline T0& RD(T0 &x0, T1 &x1, T2 &x2){RD(x0), RD(x1), RD(x2); return x0;}
template<class T0, class T1, class T2, class T3> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3){RD(x0), RD(x1), RD(x2), RD(x3); return x0;}
template<class T0, class T1, class T2, class T3, class T4> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4); return x0;}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5); return x0;}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5, T6 &x6){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5), RD(x6); return x0;}
template<class T0, class T1> inline void OT(const T0 &x0, const T1 &x1){OT(x0), OT(x1);}
template<class T0, class T1, class T2> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2){OT(x0), OT(x1), OT(x2);}
template<class T0, class T1, class T2, class T3> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3){OT(x0), OT(x1), OT(x2), OT(x3);}
template<class T0, class T1, class T2, class T3, class T4> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4, const T5 &x5){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4, const T5 &x5, const T6 &x6){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5), OT(x6);}
inline char& RC(char &a, char &b){RC(a), RC(b); return a;}
inline char& RC(char &a, char &b, char &c){RC(a), RC(b), RC(c); return a;}
inline char& RC(char &a, char &b, char &c, char &d){RC(a), RC(b), RC(c), RC(d); return a;}
inline char& RC(char &a, char &b, char &c, char &d, char &e){RC(a), RC(b), RC(c), RC(d), RC(e); return a;}
inline char& RC(char &a, char &b, char &c, char &d, char &e, char &f){RC(a), RC(b), RC(c), RC(d), RC(e), RC(f); return a;}
inline char& RC(char &a, char &b, char &c, char &d, char &e, char &f, char &g){RC(a), RC(b), RC(c), RC(d), RC(e), RC(f), RC(g); return a;}
inline DB& RF(DB &a, DB &b){RF(a), RF(b); return a;}
inline DB& RF(DB &a, DB &b, DB &c){RF(a), RF(b), RF(c); return a;}
inline DB& RF(DB &a, DB &b, DB &c, DB &d){RF(a), RF(b), RF(c), RF(d); return a;}
inline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e){RF(a), RF(b), RF(c), RF(d), RF(e); return a;}
inline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e, DB &f){RF(a), RF(b), RF(c), RF(d), RF(e), RF(f); return a;}
inline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e, DB &f, DB &g){RF(a), RF(b), RF(c), RF(d), RF(e), RF(f), RF(g); return a;}
inline void RS(char *s1, char *s2){RS(s1), RS(s2);}
inline void RS(char *s1, char *s2, char *s3){RS(s1), RS(s2), RS(s3);}
template<class T0,class T1>inline T0& RDD(T0&a, T1&b){RDD(a),RDD(b); return a;}
template<class T0,class T1,class T2>inline T1& RDD(T0&a, T1&b, T2&c){RDD(a),RDD(b),RDD(c); return a;}
//}
/** Constant List .. **/ //{ const int gx[] = {, , , -};
const int gy[] = {, , -, };
const int MOD = int(1e9) + ;
const int INF = 0x3f3f3f3f;
const LL INFF = 0x3f3f3f3f3f3f3f3fLL;
const double PI=acos(-1.0);
const double EPS=1e-; //}
/** Add On .. **/ //{
template<class T> inline bool odd(T x){return x&;}
template<class T> inline bool even(T x){return !odd(x);}
template<class T> inline T lowbit(T x) {return x & -x;} template<class T> inline bool checkMin(T &a,const T b){return b < a ? a = b, : ;}
template<class T> inline bool checkMax(T &a,const T b){return a < b ? a = b, : ;}
template<class T> inline T min(T a, T b, T c){return min(min(a, b), c);}
template<class T> inline T max(T a, T b, T c){return max(max(a, b), c);}
template<class T> inline T min(T a, T b, T c, T d){return min(min(a, b), min(c, d));}
template<class T> inline T max(T a, T b, T c, T d){return max(max(a, b), max(c, d));}
template<class T> inline T min(T a, T b, T c, T d, T e){return min(min(min(a,b),min(c,d)),e);}
template<class T> inline T max(T a, T b, T c, T d, T e){return max(max(max(a,b),max(c,d)),e);}
template<class T> inline T sqr(T a){return a*a;}
template<class T> inline T cub(T a){return a*a*a;}
template<class T> T abs(T x){return x>?x:-x;}
inline int sgn(DB x){return x < -EPS ? - : x > EPS;}
inline int sgn(DB x, DB y){return sgn(x - y);} inline DB cos(DB a, DB b, DB c){return (sqr(a)+sqr(b)-sqr(c))/(*a*b);}
inline DB cot(DB x){return ./tan(x);};
inline DB sec(DB x){return ./cos(x);};
inline DB csc(DB x){return ./sin(x);};
//}
/** I/O Accelerator Interface .. **/ //{
#define g (c=getchar())
#define d isdigit(g)
#define p x=x*10+c-'0'
#define n x=x*10+'0'-c
#define pp l/=10,p
#define nn l/=10,n
template<class T> inline T& RD(T &x){
char c;while(!d);x=c-'';while(d)p;
return x;
}
template<class T> inline T& RDD(T &x){
char c;while(g,c!='-'&&!isdigit(c));
if (c=='-'){x=''-g;while(d)n;}
else{x=c-'';while(d)p;}
return x;
}
inline DB& RF(DB &x){
//scanf("%lf", &x);
char c;while(g,c!='-'&&c!='.'&&!isdigit(c));
if(c=='-')if(g=='.'){x=;DB l=;while(d)nn;x*=l;}
else{x=''-c;while(d)n;if(c=='.'){DB l=;while(d)nn;x*=l;}}
else if(c=='.'){x=;DB l=;while(d)pp;x*=l;}
else{x=c-'';while(d)p;if(c=='.'){DB l=;while(d)pp;x*=l;}}
return x;
}
#undef nn
#undef pp
#undef n
#undef p
#undef d
#undef g
inline char* RS(char *s){
//gets(s);
scanf("%s", s);
return s;
} int Case=;template<class T> inline void OT(const T &x){
//printf("Case #%d: ", ++Case);
//printf("%I64d\n", x);
//printf("%.9f\n", x);
printf("%d\n", x);
//cout << x << endl;
//last_ans = x;
}
//}/* .................................................................................................................................. */
/** My Add Part .. **/ //{
template<class T>inline void OA(const T &a,const int &st,const int &ed){
if(ed>=st)cout<<a[st];
int i;
FOR(i,st+,ed)cout<<' '<<a[i];
puts("");
}
//} const int maxn=;
char s[maxn];
int l[maxn],r[maxn];
int a,b; int ans;
int n; bool farm(){
int i,j;
n=strlen(s);
mz(r);
mz(l);
l[]=s[]-'';
l[]%=a;
FOR(i,,n-){
l[i]=l[i-]* + s[i]-'';
l[i]%=a;
} r[n-] = s[n-]-'';
r[n-]%=b;
j=;
FORD(i,n-,){
r[i]=j*(s[i]-'') + r[i+];
r[i]%=b;
j*=;
j%=b;
}
FOR(i,,n-){
//printf("%d: %d,%d\n",i,l[i-1],r[i]);
if(s[i]!='' && l[i-]== && r[i]==){
ans=i;
return ;
}
}
return ;
} int main(){
int i,j,x,y;
RS(s);
RD(a,b);
if(farm()){
puts("YES");
REP(i,ans)putchar(s[i]);
puts("");
FOR(i,ans,n-)putchar(s[i]);
puts("");
}else puts("NO");
return ;
}

D 我搞了个BFS果然FST了! There is a hole in my brain! 其实我对这种约数的都不太懂,数学硬伤。这个题我们只能除以2或者除以3嘛,我们就把它面积搞成有相同个数的因数二和相同个数的因数三就行,搞完了他们还不等我们也没办法,就输出不行。

 /** Header .. **/ //{
//#pragma comment(linker, "/STACK:102400000,102400000")
#include<cmath>
#include<ctime>
#include<cstdio>
#include<cstring>
#include<climits>
#include<cstdlib>
#include<iostream>
#include<map>
#include<set>
#include<list>
#include<stack>
#include<queue>
#include<vector>
#include<bitset>
#include<algorithm>
#include<functional> using namespace std;
#define ALL(A) A.begin(), A.end()
#define LLA(A) A.rbegin(), A.rend()
#define mz(array) memset(array, 0, sizeof(array))
#define mf1(array) memset(array, -1, sizeof(array))
#define minf(array) memset(array, 0x3f, sizeof(array))
#define REP(i,n) for(i=0;i<(n);i++)
#define REP_1(i,n) for (i=1;i<=n;++i)
#define FOR(i,x,y) for(i=x;i<=y;i++)
#define FORD(i,x,y) for(i=x;i>=y;i--)
#define RE freopen("caravan.in","r",stdin)
#define WE freopen("caravan.out","w",stdout)
#define mp make_pair
#define pb push_back
#define pf push_front
#define ppf pop_front
#define ppb pop_back
#define lson l, m, rt << 1
#define rson m + 1, r, rt << 1 | 1
#define Rush for(int ____T=RD(); ____T--;)
#define TR(x) while(scanf("%d",&x)!=EOF)
#define Display(A, n, m) { \
REP(i, n){ \
REP(j, m-) cout << A[i][j] << " "; \
cout << A[i][m-] << endl; \
} \
}
#define Display_1(A, n, m) { \
REP_1(i, n){ \
REP_1(j, m-) cout << A[i][j] << " "; \
cout << A[i][m] << endl; \
} \
} typedef long long LL;
typedef unsigned long long uLL;
typedef double DB;
typedef long double LD;
typedef unsigned uint; typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<string> VS;
typedef vector<LL> VL;
typedef vector<DB> VF;
typedef set<int> SI;
typedef set<string> SS;
typedef map<int, int> MII;
typedef map<string, int> MSI;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef vector<VII> VVII; template<class T> inline T& RD(T &);
template<class T> inline void OT(const T &);
//inline int RD(){int x; return RD(x);}
inline LL RD() {
LL x;
return RD(x);
}
inline DB& RF(DB &);
inline DB RF() {
DB x;
return RF(x);
}
inline char* RS(char *s);
inline char& RC(char &c);
inline char RC();
inline char& RC(char &c) {
scanf(" %c", &c);
return c;
}
inline char RC() {
char c;
return RC(c);
}
//inline char& RC(char &c){c = getchar(); return c;}
//inline char RC(){return getchar();} template<class T> inline T& RDD(T &);
inline LL RDD() {
LL x;
return RDD(x);
} template<class T0, class T1> inline T0& RD(T0 &x0, T1 &x1) {
RD(x0), RD(x1);
return x0;
}
template<class T0, class T1, class T2> inline T0& RD(T0 &x0, T1 &x1, T2 &x2) {
RD(x0), RD(x1), RD(x2);
return x0;
}
template<class T0, class T1, class T2, class T3> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3) {
RD(x0), RD(x1), RD(x2), RD(x3);
return x0;
}
template<class T0, class T1, class T2, class T3, class T4> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4) {
RD(x0), RD(x1), RD(x2), RD(x3), RD(x4);
return x0;
}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5) {
RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5);
return x0;
}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5, T6 &x6) {
RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5), RD(x6);
return x0;
}
template<class T0, class T1> inline void OT(const T0 &x0, const T1 &x1) {
OT(x0), OT(x1);
}
template<class T0, class T1, class T2> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2) {
OT(x0), OT(x1), OT(x2);
}
template<class T0, class T1, class T2, class T3> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3) {
OT(x0), OT(x1), OT(x2), OT(x3);
}
template<class T0, class T1, class T2, class T3, class T4> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4) {
OT(x0), OT(x1), OT(x2), OT(x3), OT(x4);
}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4, const T5 &x5) {
OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5);
}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4, const T5 &x5, const T6 &x6) {
OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5), OT(x6);
}
inline char& RC(char &a, char &b) {
RC(a), RC(b);
return a;
}
inline char& RC(char &a, char &b, char &c) {
RC(a), RC(b), RC(c);
return a;
}
inline char& RC(char &a, char &b, char &c, char &d) {
RC(a), RC(b), RC(c), RC(d);
return a;
}
inline char& RC(char &a, char &b, char &c, char &d, char &e) {
RC(a), RC(b), RC(c), RC(d), RC(e);
return a;
}
inline char& RC(char &a, char &b, char &c, char &d, char &e, char &f) {
RC(a), RC(b), RC(c), RC(d), RC(e), RC(f);
return a;
}
inline char& RC(char &a, char &b, char &c, char &d, char &e, char &f, char &g) {
RC(a), RC(b), RC(c), RC(d), RC(e), RC(f), RC(g);
return a;
}
inline DB& RF(DB &a, DB &b) {
RF(a), RF(b);
return a;
}
inline DB& RF(DB &a, DB &b, DB &c) {
RF(a), RF(b), RF(c);
return a;
}
inline DB& RF(DB &a, DB &b, DB &c, DB &d) {
RF(a), RF(b), RF(c), RF(d);
return a;
}
inline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e) {
RF(a), RF(b), RF(c), RF(d), RF(e);
return a;
}
inline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e, DB &f) {
RF(a), RF(b), RF(c), RF(d), RF(e), RF(f);
return a;
}
inline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e, DB &f, DB &g) {
RF(a), RF(b), RF(c), RF(d), RF(e), RF(f), RF(g);
return a;
}
inline void RS(char *s1, char *s2) {
RS(s1), RS(s2);
}
inline void RS(char *s1, char *s2, char *s3) {
RS(s1), RS(s2), RS(s3);
}
template<class T0,class T1>inline T0& RDD(T0&a, T1&b) {
RDD(a),RDD(b);
return a;
}
template<class T0,class T1,class T2>inline T1& RDD(T0&a, T1&b, T2&c) {
RDD(a),RDD(b),RDD(c);
return a;
}
//}
/** Constant List .. **/ //{ const int gx[] = {, , , -};
const int gy[] = {, , -, };
const int MOD = int(1e9) + ;
const int INF = 0x3f3f3f3f;
const LL INFF = 0x3f3f3f3f3f3f3f3fLL;
const double PI=acos(-1.0);
const double EPS=1e-; //}
/** Add On .. **/ //{
template<class T> inline bool odd(T x) {
return x&;
}
template<class T> inline bool even(T x) {
return !odd(x);
}
template<class T> inline T lowbit(T x) {
return x & -x;
} template<class T> inline bool checkMin(T &a,const T b) {
return b < a ? a = b, : ;
}
template<class T> inline bool checkMax(T &a,const T b) {
return a < b ? a = b, : ;
}
template<class T> inline T min(T a, T b, T c) {
return min(min(a, b), c);
}
template<class T> inline T max(T a, T b, T c) {
return max(max(a, b), c);
}
template<class T> inline T min(T a, T b, T c, T d) {
return min(min(a, b), min(c, d));
}
template<class T> inline T max(T a, T b, T c, T d) {
return max(max(a, b), max(c, d));
}
template<class T> inline T min(T a, T b, T c, T d, T e) {
return min(min(min(a,b),min(c,d)),e);
}
template<class T> inline T max(T a, T b, T c, T d, T e) {
return max(max(max(a,b),max(c,d)),e);
}
template<class T> inline T sqr(T a) {
return a*a;
}
template<class T> inline T cub(T a) {
return a*a*a;
}
template<class T> T abs(T x) {
return x>?x:-x;
}
inline int sgn(DB x) {
return x < -EPS ? - : x > EPS;
}
inline int sgn(DB x, DB y) {
return sgn(x - y);
} inline DB cos(DB a, DB b, DB c) {
return (sqr(a)+sqr(b)-sqr(c))/(*a*b);
}
inline DB cot(DB x) {
return ./tan(x);
};
inline DB sec(DB x) {
return ./cos(x);
};
inline DB csc(DB x) {
return ./sin(x);
};
//}
/** I/O Accelerator Interface .. **/ //{
#define g (c=getchar())
#define d isdigit(g)
#define p x=x*10+c-'0'
#define n x=x*10+'0'-c
#define pp l/=10,p
#define nn l/=10,n
template<class T> inline T& RD(T &x) {
char c;
while(!d);
x=c-'';
while(d)p;
return x;
}
template<class T> inline T& RDD(T &x) {
char c;
while(g,c!='-'&&!isdigit(c));
if (c=='-') {
x=''-g;
while(d)n;
} else {
x=c-'';
while(d)p;
}
return x;
}
inline DB& RF(DB &x) {
//scanf("%lf", &x);
char c;
while(g,c!='-'&&c!='.'&&!isdigit(c));
if(c=='-')if(g=='.') {
x=;
DB l=;
while(d)nn;
x*=l;
} else {
x=''-c;
while(d)n;
if(c=='.') {
DB l=;
while(d)nn;
x*=l;
}
}
else if(c=='.') {
x=;
DB l=;
while(d)pp;
x*=l;
} else {
x=c-'';
while(d)p;
if(c=='.') {
DB l=;
while(d)pp;
x*=l;
}
}
return x;
}
#undef nn
#undef pp
#undef n
#undef p
#undef d
#undef g
inline char* RS(char *s) {
//gets(s);
scanf("%s", s);
return s;
} int Case=;
template<class T> inline void OT(const T &x) {
//printf("Case #%d: ", ++Case);
//printf("%I64d\n", x);
//printf("%.9f\n", x);
printf("%d\n", x);
//cout << x << endl;
//last_ans = x;
}
//}/* .................................................................................................................................. */
/** My Add Part .. **/ //{
template<class T>inline void OA(const T &a,const int &st,const int &ed) {
if(ed>=st)cout<<a[st];
int i;
FOR(i,st+,ed)cout<<' '<<a[i];
puts("");
}
//} int a0,b0,a1,b1; int farm() {
int i, j, k, x , y ,z;
int t0= , t1 = ;
LL t;
t=(LL)a0 * b0;
while(t%==) t/=, t0++;
t=(LL)a1 * b1;
while(t%==) t/=, t1++;
int ans = abs(t0-t1);
while(t0>t1){
if(a0%==)a0=a0*/;
else b0=b0*/;
t0--;
}
while(t1>t0){
if(a1%==)a1=a1*/;
else b1=b1*/;
t1--;
}
t=(LL)a0*b0;
t0=t1=;
while(t%==)t/=, t0++;
t=(LL)a1*b1;
while(t%==)t/=, t1++;
ans+=abs(t0-t1);
while(t0>t1){
if(a0%==)a0=a0/;
else b0=b0/;
t0--;
}
while(t1>t0){
if(a1%==)a1=a1/;
else b1=b1/;
t1--;
}
if((LL)a0*b0 == (LL)a1*b1)return ans;
return -;
} int main() {
RD(a0, b0, a1, b1 );
int ans=farm();
OT(ans);
if(ans!=-) {
printf("%d %d\n%d %d\n",a0, b0, a1, b1);
}
return ;
}

E 哇,竟然是乱搞大水题,我都怕

 /** Header .. **/ //{
//#pragma comment(linker, "/STACK:102400000,102400000")
#include<cmath>
#include<ctime>
#include<cstdio>
#include<cstring>
#include<climits>
#include<cstdlib>
#include<iostream>
#include<map>
#include<set>
#include<list>
#include<stack>
#include<queue>
#include<vector>
#include<bitset>
#include<algorithm>
#include<functional> using namespace std;
#define mz(array) memset(array, 0, sizeof(array))
#define mf1(array) memset(array, -1, sizeof(array))
#define minf(array) memset(array, 0x3f, sizeof(array))
#define REP(i,n) for(i=0;i<(n);i++)
#define REP_1(i,n) for (i=1;i<=n;++i)
#define FOR(i,x,y) for(i=x;i<=y;i++)
#define FORD(i,x,y) for(i=x;i>=y;i--)
#define RE freopen("caravan.in","r",stdin)
#define WE freopen("caravan.out","w",stdout)
#define lson l, m, rt << 1
#define rson m + 1, r, rt << 1 | 1
#define Rush for(int ____T=RD(); ____T--;)
#define TR(x) while(scanf("%d",&x)!=EOF)
#define ALL(A) A.begin(), A.end()
#define LLA(A) A.rbegin(), A.rend()
#define CPY(A, B) memcpy(A, B, sizeof(A))
#define INS(A, P, B) A.insert(A.begin() + P, B)
#define ERS(A, P) A.erase(A.begin() + P)
#define LBD(A, x) (lower_bound(ALL(A), x) - A.begin())
#define UBD(A, x) (upper_bound(ALL(A), x) - A.begin())
#define CTN(T, x) (T.find(x) != T.end())
#define SZ(A) int((A).size())
#define PB push_back
#define PPB pop_back
#define PF push_front
#define PPF pop_front
#define MP(A, B) make_pair(A, B)
#define Ts *this
#define rTs return Ts
#define fi first
#define se second
#define Display(A, n, m) { \
REP(i, n){ \
REP(j, m-) cout << A[i][j] << " "; \
cout << A[i][m-] << endl; \
} \
}
#define Display_1(A, n, m) { \
REP_1(i, n){ \
REP_1(j, m-) cout << A[i][j] << " "; \
cout << A[i][m] << endl; \
} \
} typedef long long LL;
typedef unsigned long long uLL;
typedef double DB;
typedef long double LD;
typedef unsigned uint; typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<string> VS;
typedef vector<LL> VL;
typedef vector<DB> VF;
typedef set<int> SI;
typedef set<string> SS;
typedef map<int, int> MII;
typedef map<string, int> MSI;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef vector<VII> VVII; template<class T> inline T& RD(T &);
template<class T> inline void OT(const T &);
//inline int RD(){int x; return RD(x);}
inline LL RD() {
LL x;
return RD(x);
}
inline DB& RF(DB &);
inline DB RF() {
DB x;
return RF(x);
}
inline char* RS(char *s);
inline char& RC(char &c);
inline char RC();
inline char& RC(char &c) {
scanf(" %c", &c);
return c;
}
inline char RC() {
char c;
return RC(c);
}
//inline char& RC(char &c){c = getchar(); return c;}
//inline char RC(){return getchar();} template<class T> inline T& RDD(T &);
inline LL RDD() {
LL x;
return RDD(x);
} template<class T0, class T1> inline T0& RD(T0 &x0, T1 &x1) {
RD(x0), RD(x1);
return x0;
}
template<class T0, class T1, class T2> inline T0& RD(T0 &x0, T1 &x1, T2 &x2) {
RD(x0), RD(x1), RD(x2);
return x0;
}
template<class T0, class T1, class T2, class T3> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3) {
RD(x0), RD(x1), RD(x2), RD(x3);
return x0;
}
template<class T0, class T1, class T2, class T3, class T4> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4) {
RD(x0), RD(x1), RD(x2), RD(x3), RD(x4);
return x0;
}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5) {
RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5);
return x0;
}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5, T6 &x6) {
RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5), RD(x6);
return x0;
}
template<class T0, class T1> inline void OT(const T0 &x0, const T1 &x1) {
OT(x0), OT(x1);
}
template<class T0, class T1, class T2> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2) {
OT(x0), OT(x1), OT(x2);
}
template<class T0, class T1, class T2, class T3> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3) {
OT(x0), OT(x1), OT(x2), OT(x3);
}
template<class T0, class T1, class T2, class T3, class T4> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4) {
OT(x0), OT(x1), OT(x2), OT(x3), OT(x4);
}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4, const T5 &x5) {
OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5);
}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4, const T5 &x5, const T6 &x6) {
OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5), OT(x6);
}
inline char& RC(char &a, char &b) {
RC(a), RC(b);
return a;
}
inline char& RC(char &a, char &b, char &c) {
RC(a), RC(b), RC(c);
return a;
}
inline char& RC(char &a, char &b, char &c, char &d) {
RC(a), RC(b), RC(c), RC(d);
return a;
}
inline char& RC(char &a, char &b, char &c, char &d, char &e) {
RC(a), RC(b), RC(c), RC(d), RC(e);
return a;
}
inline char& RC(char &a, char &b, char &c, char &d, char &e, char &f) {
RC(a), RC(b), RC(c), RC(d), RC(e), RC(f);
return a;
}
inline char& RC(char &a, char &b, char &c, char &d, char &e, char &f, char &g) {
RC(a), RC(b), RC(c), RC(d), RC(e), RC(f), RC(g);
return a;
}
inline DB& RF(DB &a, DB &b) {
RF(a), RF(b);
return a;
}
inline DB& RF(DB &a, DB &b, DB &c) {
RF(a), RF(b), RF(c);
return a;
}
inline DB& RF(DB &a, DB &b, DB &c, DB &d) {
RF(a), RF(b), RF(c), RF(d);
return a;
}
inline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e) {
RF(a), RF(b), RF(c), RF(d), RF(e);
return a;
}
inline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e, DB &f) {
RF(a), RF(b), RF(c), RF(d), RF(e), RF(f);
return a;
}
inline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e, DB &f, DB &g) {
RF(a), RF(b), RF(c), RF(d), RF(e), RF(f), RF(g);
return a;
}
inline void RS(char *s1, char *s2) {
RS(s1), RS(s2);
}
inline void RS(char *s1, char *s2, char *s3) {
RS(s1), RS(s2), RS(s3);
}
template<class T0,class T1>inline T0& RDD(T0&a, T1&b) {
RDD(a),RDD(b);
return a;
}
template<class T0,class T1,class T2>inline T1& RDD(T0&a, T1&b, T2&c) {
RDD(a),RDD(b),RDD(c);
return a;
}
template<class T> inline void RST(T &A){memset(A, , sizeof(A));}
template<class T> inline void FLC(T &A, int x){memset(A, x, sizeof(A));}
template<class T> inline void CLR(T &A){A.clear();} template<class T0, class T1> inline void RST(T0 &A0, T1 &A1){RST(A0), RST(A1);}
template<class T0, class T1, class T2> inline void RST(T0 &A0, T1 &A1, T2 &A2){RST(A0), RST(A1), RST(A2);}
template<class T0, class T1, class T2, class T3> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3){RST(A0), RST(A1), RST(A2), RST(A3);}
template<class T0, class T1, class T2, class T3, class T4> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5), RST(A6);}
template<class T0, class T1> inline void FLC(T0 &A0, T1 &A1, int x){FLC(A0, x), FLC(A1, x);}
template<class T0, class T1, class T2> inline void FLC(T0 &A0, T1 &A1, T2 &A2, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x);}
template<class T0, class T1, class T2, class T3> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x);}
template<class T0, class T1, class T2, class T3, class T4> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x), FLC(A5, x);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x), FLC(A5, x), FLC(A6, x);}
template<class T> inline void CLR(priority_queue<T, vector<T>, less<T> > &Q){while (!Q.empty()) Q.pop();}
template<class T> inline void CLR(priority_queue<T, vector<T>, greater<T> > &Q){while (!Q.empty()) Q.pop();}
template<class T> inline void CLR(stack<T> &S){while (!S.empty()) S.pop();}
template<class T> inline void CLR(queue<T> &Q){while (!Q.empty()) Q.pop();} //}
/** Constant List .. **/ //{ const int gx[] = {, , , -};
const int gy[] = {, , -, };
const int MOD = int(1e9) + ;
const int INF = 0x3f3f3f3f;
const LL INFF = 0x3f3f3f3f3f3f3f3fLL;
const double PI=acos(-1.0);
const double EPS=1e-; //}
/** Add On .. **/ //{
template<class T> inline bool odd(T x) {
return x&;
}
template<class T> inline bool even(T x) {
return !odd(x);
}
template<class T> inline T lowbit(T x) {
return x & -x;
} template<class T> inline bool checkMin(T &a,const T b) {
return b < a ? a = b, : ;
}
template<class T> inline bool checkMax(T &a,const T b) {
return a < b ? a = b, : ;
}
template<class T> inline T min(T a, T b, T c) {
return min(min(a, b), c);
}
template<class T> inline T max(T a, T b, T c) {
return max(max(a, b), c);
}
template<class T> inline T min(T a, T b, T c, T d) {
return min(min(a, b), min(c, d));
}
template<class T> inline T max(T a, T b, T c, T d) {
return max(max(a, b), max(c, d));
}
template<class T> inline T min(T a, T b, T c, T d, T e) {
return min(min(min(a,b),min(c,d)),e);
}
template<class T> inline T max(T a, T b, T c, T d, T e) {
return max(max(max(a,b),max(c,d)),e);
}
template<class T> inline T sqr(T a) {
return a*a;
}
template<class T> inline T cub(T a) {
return a*a*a;
}
template<class T> T abs(T x) {
return x>?x:-x;
}
inline int sgn(DB x) {
return x < -EPS ? - : x > EPS;
}
inline int sgn(DB x, DB y) {
return sgn(x - y);
} inline DB cos(DB a, DB b, DB c) {
return (sqr(a)+sqr(b)-sqr(c))/(*a*b);
}
inline DB cot(DB x) {
return ./tan(x);
};
inline DB sec(DB x) {
return ./cos(x);
};
inline DB csc(DB x) {
return ./sin(x);
};
//}
/** I/O Accelerator Interface .. **/ //{
#define g (c=getchar())
#define d isdigit(g)
#define p x=x*10+c-'0'
#define n x=x*10+'0'-c
#define pp l/=10,p
#define nn l/=10,n
template<class T> inline T& RD(T &x) {
char c;
while(!d);
x=c-'';
while(d)p;
return x;
}
template<class T> inline T& RDD(T &x) {
char c;
while(g,c!='-'&&!isdigit(c));
if (c=='-') {
x=''-g;
while(d)n;
} else {
x=c-'';
while(d)p;
}
return x;
}
inline DB& RF(DB &x) {
//scanf("%lf", &x);
char c;
while(g,c!='-'&&c!='.'&&!isdigit(c));
if(c=='-')if(g=='.') {
x=;
DB l=;
while(d)nn;
x*=l;
} else {
x=''-c;
while(d)n;
if(c=='.') {
DB l=;
while(d)nn;
x*=l;
}
}
else if(c=='.') {
x=;
DB l=;
while(d)pp;
x*=l;
} else {
x=c-'';
while(d)p;
if(c=='.') {
DB l=;
while(d)pp;
x*=l;
}
}
return x;
}
#undef nn
#undef pp
#undef n
#undef p
#undef d
#undef g
inline char* RS(char *s) {
//gets(s);
scanf("%s", s);
return s;
} int Case=;
template<class T> inline void OT(const T &x) {
//printf("Case #%d: ", ++Case);
//printf("%I64d\n", x);
//printf("%.9f\n", x);
printf("%d\n", x);
//cout << x << endl;
//last_ans = x;
}
//}/* .................................................................................................................................. */
/** My Add Part .. **/ //{
template<class T>inline void OA(const T &a,const int &st,const int &ed) {
if(ed>=st)cout<<a[st];
int i;
FOR(i,st+,ed)cout<<' '<<a[i];
puts("");
}
//} const int maxn=; char s[maxn][]; inline bool gank(int *p, int *a, const int &an, const int &now,const bool &ka){
// int i;
// REP(i,an)printf("%d ",a[i]);
// printf("(%d %d)\n",now,ka);
if(now>=an){
if(!ka)return ;
else return ;
}
if(a[now]==-){
if(!ka){
a[now]=;
return gank(p,a,an,now+,);
}else{
a[now]=p[now];
if(gank(p,a,an,now+,))return ;
a[now]=-;
if(p[now]==)return ;
a[now]=p[now]+;
if(gank(p,a,an,now+,))return ;
a[now]=-;
}
}else{
if(ka&&(a[now]<p[now]))return ;
return gank(p,a,an,now+,ka &&(a[now]==p[now]));
}
return ;
} bool make(int x){
int p[];
int pn=;
int i,j,k;
for(i=;s[x-][i]!='\0';i++){
p[pn]=s[x-][i]-'';
pn++;
}
int a[];
int an=;
for(i=;s[x][i]!='\0';i++){
if(s[x][i]!='?')a[an]=s[x][i]-'';
else a[an]=-;
an++;
}
if(an<pn)return ;
if(an==pn){
if(!gank(p,a,an,,))return ;
}
if(an>pn){
if(a[]==-)a[]=;
FOR(i,,an-)if(a[i]==-)a[i]=;
}
REP(i,an)s[x][i]=a[i]+'';
return ;
} int n; bool farm(){
int i;
s[][]='';
s[][]='\0';
FOR(i,,n){
if(!make(i))return ;
}
return ;
} int main(){
int i,j,k;
RD(n);
FOR(i,,n){
scanf(" %s",s[i]);
}
if(farm()){
puts("YES");
FOR(i,,n)puts(s[i]);
}else puts("NO");
return ;
}

现在我已经不是职业选手了,只好当娱乐解说了。不过我还是想,至少上一下传说!

为了上传说首先我使用了禁忌的秘术-岛娘的头文件,虽然还用的不是很熟

然后这场开了个新小号打div2,体验从4往1做的套路,然后34都FST了,居然变绿了,我都尿。

明明上次的第四题是暴力题!这次的我不太擅长。不过为了上传说当然要熟悉各种套路才行。

Codeforces Round #279 (Div. 2) ABCDE的相关教程结束。

《Codeforces Round #279 (Div. 2) ABCDE.doc》

下载本文的Word格式文档,以方便收藏与打印。