QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#197459 | #5140. Frozen Scoreboard | wjwHHH | WA | 0ms | 3828kb | C++14 | 6.4kb | 2023-10-02 16:10:50 | 2023-10-02 16:10:51 |
Judging History
answer
#include <bits/stdc++.h>
#define dug(x) cerr << "死了吧小丑" << x << endl
using namespace std;
using i64 = long long;
template <class T> void chmax(T &a, T b)
{
a > b ? (a = a) : (a = b);
}
template <class T> void chmin(T &a, T b)
{
a > b ? (a = b) : (a = a);
}
int m;
void solve()
{
int hasti, hastime;
cin >> hasti >> hastime;
int ingn = 0, ingm = 0;
vector<int> ta, tb, xu;
vector<string> fl(m);
vector<string> has(m);
for (int i = 0; i < m; i++)
{
cin >> fl[i];
if (fl[i] == "?")
{
int a, b;
cin >> a >> b;
ta.push_back(a);
tb.push_back(b - a);
xu.push_back(i);
}
else if (fl[i] == "+")
{
ingn++;
cin >> has[i];
int si = 0;
for (auto c : has[i])
{
if (c == '/')
{
ingm += (si - 1) * 20;
si = 0;
}
else
si = si * 10 + c - '0';
}
ingm += si;
}
else if (fl[i] == "-")
{
cin >> has[i];
}
}
bool flag = false;
vector<int> st(xu.size());
function<void(int)> dfs = [&](int idx) {
if (flag)
return;
if (idx == xu.size())
{
int cnt = 0;
for (auto c : st)
{
cnt += c;
}
if (ingn + cnt != hasti)
return;
int minn = ingm, mmax = ingm;
cnt = 0;
for (int i = 0; i < xu.size(); i++)
{
if (st[i])
{
minn += 240 + 20 * tb[i];
mmax += 299 + 20 * tb[i];
cnt += ta[i] - 1;
}
}
if (hastime >= minn && hastime <= mmax)
{
cout << "Yes" << endl;
int ingtime = minn;
vector<int> need(xu.size());
for (int i = 0; i < xu.size(); i++)
{
if (!st[i])
continue;
if (hastime - ingtime < 59)
{
need[i] = hastime - ingtime;
ingtime += hastime - ingtime;
}
else
{
ingtime += 59;
need[i] = 59;
}
}
int idx = 0;
for (int i = 0; i < m; i++)
{
if (fl[i] != "?")
{
cout << fl[i];
if (fl[i] != ".")
{
cout << " " << has[i];
}
}
else
{
if (st[idx])
{
cout << "+ ";
cout << tb[idx] + 1 << "/";
cout << need[idx] + 240;
}
else
{
cout << "- ";
cout << ta[i] + tb[i];
}
idx++;
}
cout << '\n';
}
}
else if (hastime < minn)
{
return;
}
else
{
int siz = (hastime - mmax - 1) / 20 + 1;
if (siz > cnt)
{
return;
}
vector<int> cnr(xu.size());
int ingtime = hastime - 20 * siz;
if (ingtime < minn)
{
return;
}
cout << "Yes" << endl;
ingtime = minn + 20 * siz;
for (int i = 0; i < xu.size(); i++)
{
if (!st[i])
continue;
int re = min(ta[i] - 1, siz);
cnr[i] = re;
siz -= re;
}
vector<int> need(xu.size());
for (int i = 0; i < xu.size(); i++)
{
if (!st[i])
continue;
if (hastime - ingtime < 59)
{
need[i] = hastime - ingtime;
ingtime += hastime - ingtime;
}
else
{
ingtime += 59;
need[i] = 59;
}
}
int idx = 0;
for (int i = 0; i < m; i++)
{
if (fl[i] != "?")
{
cout << fl[i];
if (fl[i] != ".")
{
cout << " " << has[i];
}
}
else
{
// cout << st[0] << st[1] << idx << endl;
if (st[idx])
{
cout << "+ ";
cout << tb[idx] + 1 + cnr[idx] << '/';
cout << need[idx] + 240;
}
else
{
cout << "- ";
cout << ta[i] + tb[i];
}
idx++;
}
cout << '\n';
}
}
flag = true;
return;
}
dfs(idx + 1);
st[idx] = 1;
dfs(idx + 1);
st[idx] = 0;
};
dfs(0);
if (!flag)
cout << "No" << endl;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout << setprecision(15) << fixed;
int t;
cin >> t;
cin >> m;
while (t--)
{
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3512kb
input:
1 13 7 951 + 1/6 ? 3 4 + 4/183 - 2 + 3/217 . . . + 2/29 + 1/91 . + 1/22 .
output:
Yes + 1/6 + 2/263 + 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: 3624kb
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 - 100 + 87/280
result:
ok ok (6 test cases)
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3828kb
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 - 5 - 0 - 5 + 1/258 + 3/240 - 5 + 1/165 - 6 + 4/240 Yes - 2 - 9 . - 1 - 7 - 6 + 4/179 - 2 - 2 . - 2 + 3/291 . Yes . - 2 . - 2 - 1 - 2 - 2 . . . . + 3/100 . Yes + 1/195 . . . . . . . . - 43772 . . . Yes . . . . . . . . . . . . . Yes - 22 - 8 - 6 + 1/173 - 11 - 0 - 3 - 6 + ...
result:
wrong answer Integer 0 violates the range [1, 100] (test case 1)