QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#596380#5140. Frozen Scoreboardlouhao088#WA 0ms3780kbC++232.8kb2024-09-28 15:39:342024-09-28 15:39:34

Judging History

你现在查看的是最新测评结果

  • [2024-09-28 15:39:34]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3780kb
  • [2024-09-28 15:39:34]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
inline int read(){
    char ch=getchar();int x=0;bool f=0;
    for(;!isdigit(ch);ch=getchar());
    for(;isdigit(ch);ch=getchar())x=(x<<1)+(x<<3)+(ch^48);
    return x;
}
const int N = 13;
int T, m;
int n, t, x[N], y[N], L[N], R[N];
char op[N];
bool sp[N];

void slove() {
    scanf("%d %d", &n, &t);
    for (int i = 0; i < m; i++) {
        op[i] = getchar();
        while (op[i] != '?' && op[i] != '+' && op[i] != '-' && op[i] != '.') op[i] = getchar();
        L[i] = R[i] = 0; sp[i] = 0;
        if (op[i] == '.') continue;
        if (op[i] == '-') {
            scanf("%d", &x[i]);
            continue;
        }
        if (op[i] == '+') {
            x[i] = read(); y[i] = read();
            L[i] = R[i] = (x[i] - 1) * 20 + y[i];
            n--;
            continue;
        }
        if (op[i] == '?') {
            x[i] = read(); y[i] = read();
            sp[i] = 1;
            L[i] = 20 * (y[i] - x[i]) + 240; R[i] = 20 * (y[i] - 1) + 299;
        }
    }
    for (int S = 0; S < (1 << m); S++) {
        bool yes = 1; int num = 0, sL = 0, sR = 0;
        for (int i = 0; i < m; i++) {
            if (op[i] == '+' && !((S >> i) & 1)) {yes = 0; break;}
            if ((op[i] == '-' || op[i] == '.') && ((S >> i) & 1)) {yes = 0; break;}
            if (op[i] == '?' && ((S >> i) & 1)) num++;
            if ((S >> i) & 1) sL += L[i], sR += R[i];
        }
        if (num != n || !yes) continue;
        if (t < sL || t > sR) continue;
        
        for (int i = 0; i < m; i++)
            if (op[i] == '?') {
                if (!((S >> i) & 1)) {
                    op[i] = '-'; x[i] = y[i];
                    continue;
                }
                sL -= L[i]; sR -= R[i]; int tm = 0;
                for (int j = L[i]; j <= R[i]; j++) {
                    if (sL + j <= t && t <= sR + j) {
                        tm = j; break;
                    }
                }
                int xx = (tm - 240) / 20, yy = tm - xx * 20;
                while (xx + 1 > y[i]) xx--, yy += 20;
                x[i] = xx + 1; y[i] = yy; t -= tm;
                op[i] = '+';
            }
            else {
                if ((S >> i) & 1) {
                    sL -= L[i]; sR -= R[i];//L[i]=R[i]
                    t -= L[i];
                }
            }
        
        printf("Yes\n");
        for (int i = 0; i < m; i++) {
            putchar(op[i]);
            if (op[i] == '.') continue;
            putchar(' ');
            if (op[i] == '-') printf("%d\n", x[i]);
            if (op[i] == '+') printf("%d/%d\n", x[i], y[i]);
        }

        return ;
    }
    printf("No\n");
}

int main() {
    scanf("%d %d", &T, &m);
    while (T--) {
        slove();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3780kb

input:

1 13
7 951
+ 1/6
? 3 4
+ 4/183
- 2
+ 3/217
.
.
.
+ 2/29
+ 1/91
.
+ 1/22
.

output:

Yes
+ 1/6
+ 3/243
+ 4/183
- 2
+ 3/217
...+ 2/29
+ 1/91
.+ 1/22
.

result:

wrong answer Token parameter [name=verdict] equals to "...+", doesn't correspond to pattern "+|-|." (test case 1)