QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#770740 | #5140. Frozen Scoreboard | ssx | WA | 3ms | 12016kb | C++20 | 5.0kb | 2024-11-21 23:49:05 | 2024-11-21 23:49:05 |
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)
{
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 (a == 0);
else
{
if (cnt != a) continue;
}
ok = 0;
for (int j = 1; j <= m; j++)
{
if ((st[j] == 0 && v1[j] == 1) || (st[j] == 1 && v1[j] == 0))
{
ok = 1;
break;
}
}
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
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 3ms
memory: 10008kb
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: -100
Wrong Answer
time: 3ms
memory: 12016kb
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 Yes + 1/1 + 1/2 Yes - 5 - 6 Yes + 1/240 + 1/240 No Yes - 100 - 100
result:
wrong answer wrong total time (test case 2)