QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#770527#5140. Frozen ScoreboardssxWA 0ms11952kbC++204.7kb2024-11-21 22:13:132024-11-21 22:13:17

Judging History

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

  • [2024-11-21 22:13:17]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:11952kb
  • [2024-11-21 22:13:13]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

#define pll pair<ll, ll>
#define ll long long
const int mod = 1e9 + 7;
const int N = 2e5 + 50;

ll m, a, b, st[N], x[N], y[N];
ll v[N], d[N], d2[N];
char c0[N];

pll get(string s)
{
    ll ok = 0, a = 0, b = 0, p = 0;
    vector<ll> v1, v2;
    for (int i = s.length() - 1; i >= 0; i--)
    {
        if (s[i] == '/')
        {
            ok = 1;
            continue;
        }
        if (ok == 0) v2.push_back(s[i] - '0');
        else v1.push_back(s[i] - '0');
    }
    for (int i = 0; i < v1.size(); i++)
    {
        a += pow(10, p) * v1[i];
        p ++;
    }
    p = 0;
    for (int i = 0; i < v2.size(); i++)
    {
        b += pow(10, p) * v2[i];
        p ++;
    }
    return {a, b};
}

pll a0;

void solve()
{
    for (int i = 0; i <= m + 1; i++)
    {
        st[i] = 0;
        v[i] = 0;
    }
    ll cnt, ok = 0;
    cin >> a >> b;
    char c;
    string s;
    cnt = 0;
    for (int i = 1; i <= m; i++)
    {
        cin >> c;
        c0[i] = c;
        if (c == '.') 
        {
            continue;
        }
        if (c == '+')
        {
            cin >> s;
            a0 = get(s);
            x[i] = a0.first; y[i] = a0.second;
            b -= (x[i] - 1) * 20 + y[i];
            a --;
        }
        if (c == '?')
        {
            cin >> x[i] >> y[i];
            if (y[i] - x[i] > 0) b -= (y[i] - x[i]) * 20;
            v[i] = x[i];
            st[i] = 1;
            cnt ++;
        }
        if (c == '-')
        {
            cin >> x[i];
        }
    }
    //cerr << a << ' ' << b << ' ' << cnt;
    if (a < 0 || b < 0 || a > cnt || b < 240 * a)
    {
        cout << "NO" << '\n';
        return ;
    }
    cnt = 0;
    ll l = 0, r = pow(2, m) - 1, tx, b0, res1, res2;
    vector<ll> v1;
    ok = 0;
    for (int j = 0; j <= m + 1; j++) d[j] = d2[j] = -1;
    for (int i = l; i <= r; i++)
    {
        tx = i;
        cnt = 0;
        v1.clear();
        v1.push_back(0);
        while (tx > 0)
        {
            if (tx % 2 == 1) cnt ++;
            v1.push_back(tx % 2);
            tx /= 2;
        }
        for (int j = v1.size(); j <= m + 3; j++) v1.push_back(0);
        if (cnt != a) continue;
        for (int j = 1; j <= m; j++)
        {
            if ((st[j] == 0 && v1[j] == 1) || (st[j] == 1 && v1[j] == 0)) continue;
        }
        for (int j = 0; j <= m + 1; j++) d[j] = d2[j] = -1;
        b0 = b;
        b0 -= 240 * a;
        res1 = b0 / 20;
        res2 = b0 % 20;
        //cout << res1 << ' ' << res2 << '\n';
        for (int j = 1; j <= m; j++)
        {
            if (v1[j] == 0) continue;
            d[j] = 1;
            if (res1 > 0)
            {
                if (res1 > v[j] - 1)
                {
                    d[j] = v[j];
                    res1 -= v[j] - 1;
                }
                else
                {
                    d[j] = res1 + 1;
                    res1 = 0;
                }
            }
        }
        if (res1 == 0)
        {
            for (int j = 1; j <= m; j++)
            {
                if (v1[j] == 0) continue;
                d2[j] = res2;
                res2 = 0;
            }
        }
        else
        {
            res2 += res1 * 20;
            for (int j = 1; j <= m; j++)
            {
                if (v1[j] == 0) continue;
                d2[j] = 0;
                if (res2 > 59)
                {
                    d2[j] = 59;
                    res2 -= 59;
                }
                else
                {
                    d2[j] = res2;
                    res2 = 0;
                }
            }
        }
        if (res1 == 0 && res2 == 0)
        {
            ok = 1;
            break;
        }
    }
    if (ok == 1)
    {
        cout << "YES" << '\n';
        for (int i = 1; i <= m; i++)
        {
            if (c0[i] == '+') cout << c0[i] << ' ' << x[i] << '/' << y[i] << '\n';
            if (c0[i] == '-') cout << c0[i] << ' ' << x[i] << '\n';
            if (c0[i] == '.') cout << c0[i] << '\n';
            if (c0[i] == '?')
            {
                if (d[i] == -1)
                {
                    cout << '-' << ' ' << y[i] << '\n';
                    continue;
                }
                cout << '+' << ' ' << y[i] - x[i] + d[i] << '/' << 240 + d2[i] << '\n';
            }
        }
    }
    else cout << "NO" << '\n';

}


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll T = 1;
    cin >> T >> m;
    while (T --)
    {
        solve();
    }
    
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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=yesno] equals to "YES", doesn't correspond to pattern "Yes|No" (test case 1)