本文共 1970 字,大约阅读时间需要 6 分钟。
字符串水题,这么做可能比较巧妙。
1 /* 1462 */ 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 10 #include 11 #include 12 #include 13 #include 14 #include 15 #include 16 #include 17 #include 18 #include 19 #include 20 #include 21 using namespace std; 22 //#pragma comment(linker,"/STACK:102400000,1024000") 23 24 #define sti set 25 #define stpii set > 26 #define mpii map 27 #define vi vector 28 #define pii pair 29 #define vpii vector > 30 #define rep(i, a, n) for (int i=a;i =a;--i) 32 #define clr clear 33 #define pb push_back 34 #define mp make_pair 35 #define fir first 36 #define sec second 37 #define all(x) (x).begin(),(x).end() 38 #define SZ(x) ((int)(x).size()) 39 #define lson l, mid, rt<<1 40 #define rson mid+1, r, rt<<1|1 41 42 const int maxn = 30; 43 char M[maxn][maxn]; 44 char hs1[maxn], vs1[maxn], hs2[maxn], vs2[maxn]; 45 int ph1, pv1, ph2, pv2; 46 int hmark[26], vmark[26]; 47 48 bool f(char *hs, char *vs, int& ph, int& pv) { 49 int hlen = strlen(hs); 50 int vlen = strlen(vs); 51 52 memset(hmark, -1, sizeof(hmark)); 53 memset(vmark, -1, sizeof(vmark)); 54 rep(i, 0, hlen) { 55 if (hmark[hs[i]-'A'] < 0) 56 hmark[hs[i]-'A'] = i; 57 } 58 59 rep(i, 0, vlen) { 60 if (vmark[vs[i]-'A'] < 0) 61 vmark[vs[i]-'A'] = i; 62 } 63 64 rep(i, 0, hlen) { 65 if (vmark[hs[i]-'A'] >= 0) { 66 ph = i; 67 pv = vmark[hs[i]-'A']; 68 return true; 69 } 70 } 71 72 return false; 73 } 74 75 void solve() { 76 memset(M, ' ', sizeof(M)); 77 int hlen1 = strlen(hs1), hlen2 = strlen(hs2); 78 int vlen1 = strlen(vs1), vlen2 = strlen(vs2); 79 80 int c1 = ph1, c2 = ph2+hlen1+3; 81 int r = max(pv1, pv2); 82 int i, j, k = 0; 83 84 // vertical 85 int r1, r2; 86 int mx = 0; 87 88 if (pv1 >= pv2) { 89 r1 = 0; 90 r2 = pv1-pv2; 91 } else { 92 r2 = 0; 93 r1 = pv2-pv1; 94 } 95 96 for (i=0; i
转载于:https://www.cnblogs.com/bombe1013/p/4924670.html