QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#672552 | #5140. Frozen Scoreboard | Repeater# | WA | 0ms | 3604kb | C++20 | 3.0kb | 2024-10-24 17:24:16 | 2024-10-24 17:24:16 |
Judging History
answer
#include <bits/stdc++.h>
void solve(int m)
{
int a, b; std::cin >> a >> b;
std::vector<std::tuple<char, int, int>> prob(m);
for(int i = 0; i < m; i++)
{
char op; std::cin >> op;
if(op == '.') prob[i] = {'.', 0, 0};
else if(op == '-')
{
int x; std::cin >> x;
prob[i] = {'-', x, 0};
}
else if(op == '+')
{
std::string s; std::cin >> s;
int x = 0, y = 0;
for(auto i : s)
{
if(i == '/')
{
x = y, y = 0;
continue;
}
y = y * 10 + (i - '0');
}
prob[i] = {'+', x, y};
b -= y + (x - 1) * 20;
a--;
}
else
{
int x, y; std::cin >> x >> y;
prob[i] = {'?', x, y};
}
}
// std::cout << a << " " << b << "\n";
std::multiset<std::pair<int, int>> Good;
std::multiset<std::pair<int, int>, std::greater<>> Bad;
int cur = 0;
for(auto [op, x, y] : prob)
{
if(op != '?') continue;
Good.emplace((y - x) * 20 + 240, cur);
Bad.emplace((y - 1) * 20 + 299, cur);
cur++;
}
int down = 0, up = 0;
cur = 0;
for(auto [time, id] : Good)
{
if(cur == a) break;
down += time;
cur++;
}
cur = 0;
for(auto [time, id] : Bad)
{
if(cur == a) break;
up += time;
cur++;
}
if(b > up || b < down)
{
std::cout << "No\n";
return;
}
std::cout << "Yes\n";
cur = 0;
for(auto [op, x, y] : prob)
{
if(op == '.') std::cout << ".\n";
else if(op == '-') std::cout << "- " << x << "\n";
else if(op == '+') std::cout << "+ " << x << "/" << y << "\n";
else
{
if(a == 0) std::cout << "- " << y << "\n";
else
{
int tGood = (y - x) * 20 + 240, tBad = (y - 1) * 20 + 299;
Good.erase(std::make_pair(tGood, cur));
Bad.erase(std::make_pair(tBad, cur));
int cnt = 0;
int sumGood = 0, sumBad = 0;
for(auto [time, id] : Good)
{
if(cnt == a - 1) break;
sumGood += time;
cnt++;
}
cnt = 0;
for(auto [time, id] : Bad)
{
if(cnt == a - 1) break;
sumBad += time;
cnt++;
}
if(b >= tGood + sumGood && b <= tBad + sumBad)
{
if(b >= tBad + sumGood)
{
b -= tBad;
a--;
std::cout << "+ " << y << "/" << 299 << "\n";
}
else
{
int t = b - sumGood - (y - x) * 20;
int ty = y - x + 1;
// std::cerr << sumGood << "\n";
while(t - 20 >= 240 && ty <= y)
{
// std::cerr << t << "\n";
ty++;
t -= 20;
}
b = sumGood;
a--;
// std::cout << "*\n";
std::cout << "+ " << ty << "/" << t << "\n";
}
}
else std::cout << "- " << y << "\n";
}
}
cur++;
}
}
int main()
{
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int n, m; std::cin >> n >> m;
while(n--) solve(m);
return 0;
}
/*
1 13
7 951
+ 1/6
? 3 4
+ 4/183
- 2
+ 3/217
.
.
.
+ 2/29
+ 1/91
.
+ 1/22
.
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
*/
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3604kb
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: 3536kb
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: 0ms
memory: 3532kb
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 + 4/278 - 5 - 3 - 5 + 2/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 . . . Yes . . . . . . . . . . . . . Yes - 22 - 8 - 6 + 1/173 - 11 - 9 - 3 - 6 + 6/254 - ...
result:
wrong answer 4-th number of submission should be in [2, 3] (test case 1)