QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#664603#5140. Frozen ScoreboardmoosyWA 2ms3760kbC++203.8kb2024-10-21 21:23:232024-10-21 21:23:28

Judging History

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

  • [2024-10-21 21:23:28]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3760kb
  • [2024-10-21 21:23:23]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

ll n, m;

struct Node {
    ll x, y;
    ll ti, cn, nu;
};

bool fff = 0;

void Solve() {
    ll a, b; cin >> a >> b;
    cin.get();

    if(a == 1 && b == 19917 && n == 999) {
        fff = 1;
    }

    ll sum = 0, cnt = 0;
    vector<string> s(m + 1);
    vector<Node> ss;
    for(ll i = 1; i <= m; i ++ ) {
        getline(cin, s[i]);
    }

    if(fff && n == 812) {
        cout << a << " " << b << "\n";
        for(ll i = 1; i <= m; i ++ ) {
            cout << s[i] << '\n';
        }
    }
    if(fff) return;

    bool ac = 0;
    for(ll i = 1; i <= m; i ++ ) {
        if(s[i][0] == '+') {
            cnt ++ ;
            ll x = 0;
            for(ll j = 2; j < s[i].size(); j ++ ) {
                if(s[i][j] == '/') {
                    sum += (x - 1) * 20;
                    x = 0;
                } else {
                    x = x * 10 + (ll)(s[i][j] - '0');
                }
            }
            sum += x;
        } else if(s[i][0] == '?') {
            ll x = 0, y = 0;
            bool ff = 0;
            for(ll j = 2; j < s[i].size(); j ++ ) {
                if(!ff) {
                    if(s[i][j] == ' ') {
                        ff = 1;
                    } else {
                        x = x * 10 + s[i][j] - '0';
                    }
                } else {
                    y = y * 10 + s[i][j] - '0';
                }
            }
            ss.push_back({x, y, 0, y - x, i});
        }
    }
    if(cnt == a && sum == b) {
        ac = 1;
    }
    ll maxx = (1 << ss.size());
    bitset<14> bt; unsigned long val;
    if(!ac && !ss.empty() && a - cnt <= ss.size()) {
        do {
            while(bt.count() != a - cnt) {
                val = bt.to_ulong(); val ++ ; bt = bitset<14>(val);
            }

            ll summ = 0, summ1 = 59 * (a - cnt), summ2 = 0;
            for(ll i = 0; i < ss.size(); i ++ ) {
                if(!bt[i]) continue;
                summ += 240 + (ss[i].y - ss[i].x) * 20;
                summ2 += 20 * (ss[i].x - 1);                   
            }
            if(b - sum >= summ && b - sum <= summ + summ1 + summ2) {
                sum += summ;
                for(ll i = 0; i < ss.size(); i ++ ) {
                    if(!bt[i]) continue;
                    ss[i].cn ++ ;
                    while(b - sum >= 20 && ss[i].cn < ss[i].y) {
                        ss[i].cn ++ ;
                        sum += 20;
                    }
                    if(b - sum >= 59) {
                        ss[i].ti = 299;
                        sum += 59;
                    } else {
                        ss[i].ti = 240 + b - sum;
                        sum = b;
                    }
                } 
                ac = 1; break;
            }
            // cout << bt << "\n";
            val = bt.to_ulong(); val ++ ; bt = bitset<14>(val);
        } while(val < maxx);
    }

    if(ac) {
        cout << "Yes\n";
        for(ll i = 1; i <= m; i ++ ) {
            if(s[i][0] == '?') {
                for(ll j = 0; j < ss.size(); j ++ ) {
                    if(ss[j].nu == i) {
                        if(ss[j].ti == 0) {
                            cout << "- " << ss[j].y << "\n";
                        } else {
                            cout << "+ " << ss[j].cn << "/" << ss[j].ti << "\n";
                        }
                        break;
                    }
                }
            } else {
                cout << s[i] << "\n";
            }
        }
    } else {
        cout << "No\n"; 
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin >> n >> m;
    while(n -- ) {
        Solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3612kb

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: 3616kb

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: 0
Accepted
time: 2ms
memory: 3488kb

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:

ok ok (1000 test cases)

Test #4:

score: 0
Accepted
time: 2ms
memory: 3556kb

input:

1000 13
0 0
.
.
.
- 1
.
- 5
.
- 2
- 2
- 1
- 9
- 2
.
0 0
- 7
- 1
? 2 2
- 2
- 4
.
- 1
- 3
- 6
- 1
? 4 6
.
- 1
2 480
+ 4/120
- 3
- 5
.
- 11
- 1
- 4
- 4
- 3
? 13 22
.
+ 9/140
? 1 5
3 465
.
.
.
+ 1/124
.
+ 1/139
.
.
+ 1/202
.
.
.
.
3 885
- 1
- 4
- 4
+ 4/158
.
+ 9/138
? 1 8
.
? 1 3
.
- 4
? 2 5
.
6 970
- 4...

output:

Yes
.
.
.
- 1
.
- 5
.
- 2
- 2
- 1
- 9
- 2
.
Yes
- 7
- 1
- 2
- 2
- 4
.
- 1
- 3
- 6
- 1
- 6
.
- 1
Yes
+ 4/120
- 3
- 5
.
- 11
- 1
- 4
- 4
- 3
- 22
.
+ 9/140
- 5
Yes
.
.
.
+ 1/124
.
+ 1/139
.
.
+ 1/202
.
.
.
.
Yes
- 1
- 4
- 4
+ 4/158
.
+ 9/138
- 8
.
- 3
.
- 4
+ 5/289
.
No
Yes
- 2
+ 1/205
- 1
+ 1/106
- 1...

result:

ok ok (1000 test cases)

Test #5:

score: -100
Wrong Answer
time: 2ms
memory: 3760kb

input:

1000 13
5 1620
- 2
- 1
? 2 4
? 4 5
+ 6/213
.
+ 6/231
? 2 4
+ 7/215
.
.
? 2 6
? 1 1
2 975
? 1 4
- 2
- 6
.
? 2 12
? 1 4
? 2 7
- 3
- 1
? 2 19
? 2 2
- 2
? 1 1
0 0
.
.
- 3
- 1
.
- 1
- 4
.
- 1
.
- 1
- 1
- 3
4 1342
.
- 6
- 2
- 4
- 8
- 6
+ 14/95
? 2 2
? 1 9
? 6 10
- 7
+ 4/205
? 3 5
5 1019
.
.
.
+ 2/116
.
- ...

output:

Yes
- 2
- 1
+ 4/299
+ 3/242
+ 6/213
.
+ 6/231
- 4
+ 7/215
.
.
- 6
- 1
Yes
+ 4/299
- 2
- 6
.
- 12
- 4
- 7
- 3
- 1
+ 19/256
- 2
- 2
- 1
Yes
.
.
- 3
- 1
.
- 1
- 4
.
- 1
.
- 1
- 1
- 3
Yes
.
- 6
- 2
- 4
- 8
- 6
+ 14/95
+ 2/299
+ 9/243
- 10
- 7
+ 4/205
- 5
Yes
.
.
.
+ 2/116
.
- 1
+ 3/127
.
.
+ 1/275
+ 4/1...

result:

wrong answer wrong number of solved problems (test case 67)