关于这题我的做法
查看原帖
关于这题我的做法
275273
EuphoricStar楼主2021/2/9 18:56

这题我用一种貌似很对的乱搞做法A了,求hack

#include <cstdio>
#include <set>
using namespace std;

int t, n;
int dx[] = {0, 1, -1, 0}, dy[] = {-1, 0, 0, 1};
char p[3][100100];
struct node {
    int a, b;
    bool operator < (const node &c) const {
        if (a == c.a) {
            return b < c.b;
        }
        return a < c.a;
    }
};
set<node> st;

int main() {
    scanf("%d", &t);
    for (int i = 0; i < t; ++i) {
        st.clear();
        scanf("%d", &n);
        scanf("%s%s", p[0], p[1]);
        for (int y = 0; y < n; ++y) {
            for (int x = 0; x < 2; ++x) {
                if (p[x][y] == '0') {
                    continue;
                }
                for (int k = 0; k < 4; ++k) {
                    int nx = x + dx[k], ny = y + dy[k];
                    if (nx < 0 || nx > 1 || ny < 0 || ny >= n) {
                        continue;
                    }
                    if (p[nx][ny] == '0') {
                        if (st.count({nx, ny})) {
                            continue;
                        }
                        st.insert({nx, ny});
                        goto Next;
                    }
                }
                puts("++");
                goto NEXT;
                Next: ;
            }
        }
        puts("RP");
        NEXT: ;
    }
    return 0;
}
2021/2/9 18:56
加载中...