AIM Tech Round 5 (rated, Div. 1 + Div. 2)

A. Find Square

找到对角线的两个点的坐标,这道题就迎刃而解了。

inline void work(int n) {
    int m;
    cin >> m;
    memset(str, 0, sizeof(str));
    rep(i,1,n) {
        scanf("%s", str+1);
        rep(j,1,m) a[i][j] = (str[j] == 'B' ?  1 : 0);
    }

    int lx = 0, ly = 0, rx = 0, ry = 0;

    for (int i = n; i >= 1; -- i) {
        rep(j,1,m)
            if (a[i][j] == 1) {lx = i; ly = j;break;}
        if (lx != 0) break;
    }

    rep(i,1,n) {
        for (int j = m; j >= 1; -- j)
            if (a[i][j] == 1) {rx = i; ry = j;break;}
        if (rx != 0) break;
    }

    cout << (lx + rx) / 2 << " " << (ly + ry) / 2 << endl;
}

B. Unnatural Conditions

考虑到位数远远大于\(n,m\)的值,直接选择构造出\(s(a)\ >\ max(n),\ s(b)\ >\ max(m),\ s(a\ +\ b)\ = \ 1\)

inline void work(int n, int m) {
    rep(i,1,2230) cout << 5;
    cout << endl;
    rep(i,1,2229) cout << 4;
    cout << 5 << endl;
}

猜你喜欢

转载自www.cnblogs.com/Alessandro/p/9553408.html