QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#672576 | #5140. Frozen Scoreboard | Repeater# | WA | 3ms | 3604kb | C++20 | 3.6kb | 2024-10-24 17:32:06 | 2024-10-24 17:32:06 |
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;
}
cur = 0;
std::vector<std::string> ans;
for(auto [op, x, y] : prob)
{
if(op == '.') ans.emplace_back(".");
else if(op == '-')
{
std::string s = "- ";
s += std::to_string(x);
ans.emplace_back(s);
}
else if(op == '+')
{
std::string s = "+ ";
s += std::to_string(x);
s += "/";
s += std::to_string(y);
ans.emplace_back(s);
}
else
{
if(a == 0)
{
std::string s = "- ";
s += std::to_string(y);
ans.emplace_back(s);
}
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::string s = "+ ";
s += std::to_string(y);
s += "/";
s += "299";
ans.emplace_back(s);
}
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::string s = "+ ";
s += std::to_string(ty);
s += "/";
s += std::to_string(t);
ans.emplace_back(s);
}
}
else
{
std::string s = "- ";
s += std::to_string(y);
ans.emplace_back(s);
}
}
}
cur++;
}
if(a == 0 && b == 0)
{
std::cout << "Yes\n";
for(auto i : ans) std::cout << i << "\n";
}
else std::cout << "No\n";
}
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: 3540kb
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: 3604kb
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: 3552kb
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 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 - 8 - 12 - 1 + 2/229 Yes . - 1 + 2/265 - 1 + 1/60 . . - 1 . . . . . Yes . -...
result:
wrong answer ans finds the answer, but out doesn't (test case 1)