求调
查看原帖
求调
363415
251Sec楼主2022/12/4 10:37

如题,不知道为什么挂了好几个点。

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a, b;
int st[2005], top;
int ans[2005];
int main()
{
    scanf("%d%d", &a, &b);
    if (a <= b) {
        puts("Impossible");
        return 0;
    }
    for (int i = 0; i < a + b; i++) {
        if (!top) {
            st[++top] = i;
            continue;
        }
        printf("? %d %d\n", st[top], i);
        fflush(stdout);
        char c[6];
        scanf("%s", c);
        if (c[0] == 'N') {
            top--;
        }
        else {
            st[++top] = i;
        }
    }
    for (int i = 0; i < a + b; i++) {
        if (i == st[top]) {
            ans[i] = 1;
            continue;
        }
        printf("? %d %d\n", st[top], i);
        fflush(stdout);
        char c[6];
        scanf("%s", c);
        if (c[0] == 'N') {
            ans[i] = 0;
        }
        else {
            ans[i] = 1;
        }
    }
    printf("! ");
    for (int i = 0; i < a + b; i++) putchar(ans[i] + '0');
    return 0;
}
2022/12/4 10:37
加载中...