Niuke Xiaobaiyue Contest 31 H title symmetry beauty


Insert picture description here
Insert picture description here
Analysis of the beauty of symmetry in question 31 of Niuke Xiaobaiyue Competition :
In fact, after reading this question, it is not difficult to understand, only the first half of the string contains a letter in the string that is symmetrical to it.
But for this question, you can take a look at the usage of the find function in C++, there are quite a few

AC code:

#include <bits/stdc++.h>

#define ll long long
const int N = 200;
using namespace std;
string a[N];

int main() {
    
    
    ll t;
    ll n;
    cin >> t;
    for (int k = 0; k < t; k++) {
    
    
        scanf("%lld", &n);
        for (int j = 0; j < n; j++)
            cin >> a[j];
        if (n == 1) {
    
    
            printf("Yes\n");
            continue;
        }
        bool flag = true;
        int i, j;
        for (i = 0; i < n / 2; i++) {
    
    
            for (j = 0; j < a[i].length(); j++) {
    
    
                if (a[n - i - 1].find(a[i][j]) != -1) {
    
    
                    break;
                }
            }
            if (j == a[i].length()) {
    
    
                flag = false;
                break;
            }
        }
        if (flag)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}

Guess you like

Origin blog.csdn.net/qq_45654671/article/details/112452971
Recommended