1 条题解

  • 0
    @ 2025-5-29 22:34:20
    #include <bits/stdc++.h>
    #define int long long
    #define str string #define endl '\n'
    #define fst                  \
        ios::sync_with_stdio(0); \
        cin.tie(0);              \
        cout.tie(0);
    using namespace std;
    const int N = 1e6 + 5, M = 2e6 + 5;
    int P = 1e9 + 7;
    const int INF = 0x3f3f3f3f3f3f3f3f;
    const int dx[10] = {0, 0, -1, 1, -1, 1, -1, 1};
    const int dy[10] = {-1, 1, 0, 0, -1, -1, 1, 1};
    int n, m;
    int mp[105][105];
    int check(int x, int y) {
        int cant = 0;
        for (int i = 0; i < 8; i++) {
            int newx = (x + dx[i]);
            int newy = (y + dy[i]);
            if (mp[newx][newy] > mp[x][y]) {
                cant++;
            }
        }
        return ((cant == 8) ? -1 : ((cant >= 4) ? 0 : 1));
    }
    int num;
    signed main() {
        fst;
        cin >> n >> m;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                cin >> mp[i][j];
            }
            for (int i = 1; i <= n; i++) {
                for (int j = 1; j <= m; j++) num = check(i, j);
                cout << i << ' ' << j << ' ';
                if (num == -1) {
                    cout << "Unhappy";
                } else if (!num) {
                    cout << "A little unhappy";
                } else {
                    cout << "Happy";
                }
                cout << endl;
            }
        }
        return 0;
    }
    
    
    

    信息

    ID
    8475
    时间
    1000ms
    内存
    256MiB
    难度
    2
    标签
    递交数
    28
    已通过
    11
    上传者