QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#770761 | #5140. Frozen Scoreboard | ssx | WA | 26ms | 12168kb | C++20 | 5.0kb | 2024-11-21 23:59:48 | 2024-11-21 23:59:48 |
Judging History
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 << '\n';
if (a < 0 || b < 0 || a > cnt || b < 240 * a || (a == 0 && b > 0))
{
cout << "No" << '\n';
return ;
}
cnt = 0;
ll l = 0, r = pow(2, m) - 1, tx, b0, res1, res2, res0;
vector<ll> v1;
ok = 0;
for (int j = 0; j <= m + 1; j++) d[j] = d2[j] = -1;
//cout << a << '\n';
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);
ok = 0, res0 = 0;
for (int j = 1; j <= m; j++)
{
if (st[j] == 0 && v1[j] == 1)
{
ok = 1;
break;
}
if (st[j] == 1 && v1[j] == 1) res0 ++;
}
if (res0 != a) continue;
if (ok == 1) continue;
ok = 0;
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;
}
/*
1 13
6 1519
+ 3/183
- 1
+ 9/133
? 2 3
- 5
? 1 3
- 5
? 1 1
? 1 3
- 5
+ 1/165
- 6
? 2 5
*/
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 12076kb
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: 12168kb
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: 26ms
memory: 10112kb
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:
No No Yes . - 2 . - 2 - 1 - 2 - 2 . . . . + 3/100 . Yes + 1/195 . . . . . . . . - 1 . . . Yes . . . . . . . . . . . . . No Yes . - 1 + 1/285 - 1 + 1/60 . . - 1 . . . . . No No Yes + 3/209 + 1/221 . . . . + 3/103 + 4/208 + 12/289 . + 2/236 + 1/240 + 11/240 No No No Yes . . . . . . - 1 . . . + 1/129 ....
result:
wrong answer ans finds the answer, but out doesn't (test case 1)