QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#730337#5140. Frozen Scoreboardlllei#WA 1ms3964kbC++203.8kb2024-11-09 19:49:152024-11-09 19:49:16

Judging History

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

  • [2024-11-09 19:49:16]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3964kb
  • [2024-11-09 19:49:15]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using LL = long long;



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;

    vector a(m + 1, vector<vector<int>>());

    for (int i = 0; i <= m; ++i) {
        a[i].resize(i + 1);
        for (int j = 0; j < (1 << i); ++j) {
            a[i][__builtin_popcount(j)].push_back(j);
        }
    }

    while (n--) {
        int x, y;
        cin >> x >> y;
        vector<array<int, 3>> ans;
        LL al = 0;
        vector<array<int, 3>> res;
        vector<int> aa;
        int cnt = 0;
        for (int i = 0; i < m; ++i) {
            char ch;
            cin >> ch;
            if (ch == '+') {
                int a, b;
                cin >> a >> ch >> b;
                res.push_back({1, a, b});
                al += b + 20 * (a - 1);
                ++cnt;
            } else if (ch == '-') {
                int a;
                cin >> a;
                res.push_back({2, a});
            } else if (ch == '?') {
                int a, b;
                cin >> a >> b;
                res.push_back({3, a, b});
                aa.push_back(i);
            } else if (ch == '.') {
                res.push_back({0});
            } else {
                assert(0);
            }
        }

        int aas = aa.size();
        if (x < cnt && x > cnt + aas) {
            cout << "No\n";
            continue;
            
        }

        bool flag = false;
        for (int now : a[aas][x - cnt]) {
            LL mn = al, mx = al;
            int now1 = now;
            for (; now; now -= (now & -now)) {
                int z = aa[__lg(now & -now)];

                auto [_, a, b] = res[z];

                mn += 240 + (b - a) * 20;
                mx += 299 + (b - 1) * 20;
            }

            if (mn > y || mx < y) {
                continue;
            }

            flag = true;

            LL nowa = mn;
            cout << "Yes\n";
            for (int i = 0; i < m; ++i) {
                if (res[i][0] == 0) {
                    cout << ".\n";
                } else if (res[i][0] == 1) {
                    cout << "+ " << res[i][1] << "/" << res[i][2] << '\n';
                } else if (res[i][0] == 2) {
                    cout << "- " << res[i][1] << "\n";
                } else {
                    bool flag = false;
                    for (int j = 0; j < aas; ++j) {
                        if (((now1 >> j) & 1) && aa[j] == i) {
                            flag = true;
                            break;
                        }
                    }

                    if (!flag) {
                        cout << "- " << res[i][2] << "\n";
                    } else {
                        auto [_, a, b] = res[i];
                        LL mn1 = 240 + (b - a) * 20;
                        LL mx1 = 299 + (b - 1) * 20;

                        LL dis = mx1 - mn1;
                        if (dis + nowa <= y) {
                            nowa += dis;
                            cout << "+ " << b << "/" << mx1 << "\n";
                        } else {
                            LL t1 = min((y - nowa) / 20, 1LL * a - 1);
                            LL t2 = y - nowa - t1 * 20;

                            nowa = y;
                            cout << "+ " << b - a + 1 + t1 << "/" << 240 + t2 << '\n';
                        }
                    }
                }
            }
            break;
        }

        if (!flag) {
            cout << "No\n";
        }
    }
    return 0;
}

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


6 2
1 100
.
? 3 4
2 100
+ 1/1
+ 1/2
0 0
- 5
- 6
2 480
? 100 100
? 100 100
2 480
? 99 100
? 100 100
1 2000
? 100 100
? 100 100
*/

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3656kb

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:

ok ok (1 test case)

Test #2:

score: 0
Accepted
time: 0ms
memory: 3812kb

input:

6 2
1 100
.
? 3 4
2 100
+ 1/1
+ 1/2
0 0
- 5
- 6
2 480
? 100 100
? 100 100
2 480
? 99 100
? 100 100
1 2000
? 100 100
? 100 100

output:

No
No
Yes
- 5
- 6
Yes
+ 1/240
+ 1/240
No
Yes
+ 89/240
- 100

result:

ok ok (6 test cases)

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3964kb

input:

1000 13
6 1519
+ 3/183
- 1
+ 9/133
? 2 3
- 5
? 1 3
- 5
? 1 1
? 1 3
- 5
+ 1/165
- 6
? 2 5
2 570
- 2
- 9
.
- 1
- 7
- 6
+ 4/179
- 2
? 2 5
.
- 2
? 1 3
.
1 140
.
- 2
.
- 2
- 1
- 2
- 2
.
.
.
.
+ 3/100
.
1 195
+ 1/195
.
.
.
.
.
.
.
.
? 1 1
.
.
.
0 0
.
.
.
.
.
.
.
.
.
.
.
.
.
3 776
? 8 22
? 1 8
- 6
+ 1/173
...

output:

Yes
+ 3/183
- 1
+ 9/133
+ 3/278
- 5
+ 3/240
- 5
+ 1/240
- 3
- 5
+ 1/165
- 6
- 5
Yes
- 2
- 9
.
- 1
- 7
- 6
+ 4/179
- 2
+ 5/251
.
- 2
- 3
.
Yes
.
- 2
.
- 2
- 1
- 2
- 2
.
.
.
.
+ 3/100
.
Yes
+ 1/195
.
.
.
.
.
.
.
.
- 1
.
.
.
Yes
.
.
.
.
.
.
.
.
.
.
.
.
.
Yes
- 22
- 8
- 6
+ 1/173
- 11
- 9
- 3
- 6
+ 6/25...

result:

wrong answer submit time should be between 0 and 299 (test case 10)