QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#528096#5141. Identical ParitysyssTL 0ms0kbC++203.5kb2024-08-23 08:18:352024-08-23 08:18:36

Judging History

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

  • [2024-08-23 08:18:36]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-08-23 08:18:35]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long

using namespace std;

inline int read () {
    int w = 1, s = 0; char ch = getchar ();
    for (; ! isdigit (ch); ch = getchar ()) if (ch == '-') w = -1;
    for (; isdigit (ch); ch = getchar ()) s = (s << 1) + (s << 3) + (ch ^ 48);
    return s * w;
}

struct Info {
    char op[2];
    int x, y;
};

void solve () {
    int n = read (), m = read ();

    while (n --) {
        int Solve = read (), Time = read ();
        int sum = 0, sumtime = 0;
        
        vector <int> p;
        vector <Info> info (m);
        int t = 0;
        for (auto &[op, x, y] : info) {
            scanf ("%s", op);
            if (op[0] == '+') {
                scanf ("%lld/%lld", &x, &y);
                sum ++;
                sumtime += (x - 1) * 20 + y;
            } else if (op[0] == '-') {
                x = read ();
            } else if (op[0] == '?') {
                p.push_back (t);
                x = read (); y = read ();
            } 
            t ++;
        }
        if (sumtime > Time || sum > Solve) {
            printf ("No\n");
            continue;
        }

        bool ok = false;
        for (int i = 0; i < 1 << p.size (); i ++) {
            int tot = 0;
            for (int j = 0; j < p.size (); j ++) {
                if (i >> j & 1) {
                    tot ++;
                }
            }
            if (tot != Solve - sum) continue;
            int now = sumtime;
            int cnt = 0;
            for (int j = 0; j < p.size (); j ++) {
                if (i >> j & 1) {
                    auto [op, x, y] = info[p[j]];
                    now += 239 + (y - x) * 20;
                    cnt += x;
                }
            }
            now += tot;
            if (Time < now) {
                continue;
            }
            if (Time > now + (cnt-tot) * 20 + 59 * tot) {
                continue;
            }
            
            for (int j = 0; j < p.size (); j ++) {
                auto &[op, x, y] = info[p[j]];
                if (i >> j & 1) {
                    op[0] = '+';
                    int z = 0;
                    if (Time - now >= (x - 1) * 20) {
                        now += (x - 1) * 20;
                        x=y;
                    } else {
                        z = (Time - now) / 20;
                        now += z * 20;
                        x = (y - x) + z + 1;
                    }
                    if (Time - now >= 59) {
                        now += 59;
                        y = 299;
                    } else {
                        y = (Time - now) + 240;
                        now = Time;
                    }
                } else {
                    op[0] = '-';
                    x = y;
                }
            }
            ok = true;
            break;
        }
        if (ok) {
            printf ("Yes\n");
            for (auto [op, x, y] : info) {
                if (op[0] == '+') {
                    printf ("+ %lld/%lld\n", x, y);
                } else if (op[0] == '-') {
                    printf ("- %lld\n", x);
                } else {
                    printf (".\n");
                }
            }
        } else {
            printf ("No\n");
        }
    }
}

signed main () {
/*  ios::sync_with_stdio(false);
    cin.tie(nullptr);*/
    
    int TT = 1; 
//  cin >> TT;
//  TT = read ();
    while (TT --) solve ();
    
    return 0;
}

詳細信息

Test #1:

score: 0
Time Limit Exceeded

input:

3
3 1
4 2
5 3

output:


result: