QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#315082 | #5140. Frozen Scoreboard | Detach | WA | 3ms | 3648kb | C++17 | 4.2kb | 2024-01-26 22:49:25 | 2024-01-26 22:49:25 |
Judging History
answer
#include <bits/stdc++.h>
// #include <algorithm>
// #include <queue>
// #include <map>
// #include <iostream>
// #include <string>
// #include <set>
#define endl '\n'
using namespace std;
using LL = long long;
using PII = pair<int, int>;
using i128 = __int128_t;
using ULL = unsigned long long;
const int INF = 0x3f3f3f3f, MOD = 1e9 + 7, N = 1e6 + 5;
const LL LINF = 0x3f3f3f3f3f3f3f3f;
int m;
struct node
{
char op;
int x, y, idx;
};
void solve()
{
int pb, tm;
cin >> pb >> tm;
vector<struct node> a(m), b;
vector<bool> st(m);
int pas = 0, penal = 0;
for(int i = 0; i < m; i ++ )
{
char op;
int x = 0, y = 0;
cin >> op;
if(op == '.') a[i].op = op;
else if(op == '-')
{
cin >> x;
a[i] = {op, x, x, i};
}
else if(op == '?')
{
cin >> x >> y;
a[i] = {op, x, y, i};
b.push_back(a[i]);
}
else
{
string s;
cin >> s;
int len = s.size();
bool ok = false;
for(int i = 0; i < len; i ++ )
{
if(s[i] == '/') ok = true;
else
{
int k = s[i] - '0';
if(!ok) x = x * 10 + k;
else y = y * 10 + k;
}
}
a[i] = {op, x, y, i};
pas ++ , penal += 20 * (x - 1) + y;
}
}
if(pas + b.size() < pb)
{
cout << "No" << endl;
return;
}
if(pas > pb)
{
cout << "No" << endl;
return;
}
else if(pas == pb)
{
cout << (penal == tm ? "Yes" : "No") << endl;
if(penal == tm)
for(int i = 0; i < m; i ++ )
{
auto [op, x, y, idx] = a[i];
if(op == '.') cout << op << endl;
else if(op == '-') cout << op << ' ' << x << endl;
else cout << op << ' ' << x << '/' << y << endl;
}
return;
}
pas = pb - pas, penal = tm - penal;
int r = penal - pas * 240;
if(r < 0)
{
cout << "No" << endl;
return;
}
int l = r - 59 * pas;
l = max(l, 0);
l = (l + 19) / 20, r /= 20;
int n = b.size();
auto dfs = [&](auto self, int x, int num, int tot, int ft)->bool
{
if(num == pas)
{
return (tot <= r and tot + ft >= l);
}
for(int i = x; i < n; i ++ )
{
st[b[i].idx] = true;
if(self(self, i + 1, num + 1, tot + b[i].y - b[i].x, ft + b[i].x - 1)) return true;
st[b[i].idx] = false;
if(self(self, i + 1, num, tot, ft)) return true;
}
return false;
};
bool ok = dfs(dfs, 0, 0, 0, 0);
if(!ok) cout << "No" << endl;
else
{
cout << "Yes" << endl;
penal -= 240 * pas;
for(int i = 0; i < m; i ++ )
{
if(!st[i]) continue;
penal -= 20 * (a[i].y - a[i].x);
}
for(int i = 0; i < m; i ++ )
{
auto [op, x, y, idx] = a[i];
if(op == '.') cout << '.' << endl;
else if(op == '-') cout << op << ' ' << x << endl;
else if(op == '+') cout << op << ' ' << x << '/' << y << endl;
else
{
if(!st[i])
{
cout << "- " << y << endl;
}
else
{
int t = penal / 20;
int k = min(t, x - 1);
penal -= k * 20;
int kk = min(59, penal);
penal -= kk;
cout << "+ " << y - x + k + 1 << '/' << 240 + kk << endl;
}
}
}
}
}
int main()
{
// freopen("galactic.in", "r", stdin);
ios::sync_with_stdio(false), cin.tie(nullptr);
int T = 1;
cin >> T >> m;
while(T -- )
solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3648kb
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: 3596kb
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: 3ms
memory: 3600kb
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/278 - 5 + 3/240 - 5 + 1/240 - 3 - 5 + 1/165 - 6 - 5 Yes - 2 - 9 . - 1 - 7 - 6 + 4/179 - 2 + 5/251 . - 2 - 3 . Yes . - 2 . - 2 - 1 - 2 - 2 . . . . + 3/100 . Yes + 1/195 . . . . . . . . ? 1/1 . . . Yes . . . . . . . . . . . . . Yes - 22 - 8 - 6 + 1/173 - 11 - 9 - 3 - 6 + 6/...
result:
wrong answer Token parameter [name=verdict] equals to "?", doesn't correspond to pattern "+|-|." (test case 4)