QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#190930 | #5140. Frozen Scoreboard | chroneZ | WA | 0ms | 3616kb | C++17 | 2.7kb | 2023-09-29 15:58:12 | 2023-09-29 15:58:12 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
struct Query {string op; int x, y;};
pair<int, int> val(string t) {
int x = 0, y = 0, cur = 0;
for(int i = 0; i < t.size(); i++) {
if(t[i] == '/') {
cur = 1;
continue;
}
if(cur == 0) {
x = x * 10 + (t[i] ^ 48);
} else {
y = y * 10 + (t[i] ^ 48);
}
}
return {x, y};
}
struct Range {
int l, r;
inline friend Range operator + (Range x, Range y) {
return {x.l + y.l, x.r + y.r};
}
};
void solve(int m) {
int T, P; cin >> T >> P;
vector<Query> a(m);
vector<int> p; vector<Range> q;
for(int i = 0; i < m; i++) {
auto &[op, x, y] = a[i];
cin >> op;
if(op == "+") {
string t; cin >> t;
auto [v1, v2] = val(t);
x = v1, y = v2;
T--, P -= y + (x - 1) * 20;
}
if(op == "-") {
cin >> x;
}
if(op == "?") {
cin >> x >> y;
p.push_back(i);
q.push_back({(y - x) * 20 + 240, (y - 1) * 20 + 299});
}
if(op == ".") {
continue;
}
}
if(T < 0 || P < 0) {
cout << "No\n";
return;
}
for(int s = 0; s < (1 << p.size()); s++) {
if(__builtin_popcount(s) != T) {
continue;
}
Range t = {0, 0};
for(int i = 0; i < p.size(); i++) {
if(!(s >> i & 1)) continue;
t = t + q[i];
}
if(t.l <= P && P <= t.r) {
for(int i = 0; i < p.size(); i++) {
if(!(s >> i & 1)) continue;
P -= t.l;
}
for(int i = 0; i < p.size(); i++) {
if(!(s >> i & 1)) continue;
if(P <= t.r - t.l) {
cout << "Yes\n";
int tail = -1;
int id = p[i];
int occ = P / 20;
int d = min(a[id].x - 1, occ);
P -= d * 20;
for(int j = 0; j < m; j++) {
if(a[j].op != "?") {
if(a[j].op == "+") {
cout << a[j].op << " " << a[j].x << "/" << a[j].y << "\n";
}
if(a[j].op == "-") {
cout << a[j].op << " " << a[j].x << "\n";
}
if(a[j].op == ".") {
cout << a[j].op << "\n";
}
} else {
tail++;
if(!(s >> i & 1)) {
cout << "- " << a[j].y << "\n";
continue;
}
if(tail == i) {
cout << "+ " << a[j].y - a[j].x + d + 1 << "/" << 240 + P << "\n";
} else if(tail < i) {
cout << "+ " << a[j].y << "/" << 299 << "\n";
} else {
cout << "+ " << a[j].x << "/" << 240 << "\n";
}
}
}
return;
} else {
P -= t.r - t.l;
}
}
}
}
cout << "No\n";
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);
int n, m; cin >> n >> m;
while(n--) {
solve(m);
}
}
/*
Author: chroneZ
Start thinking at
Start coding at
Finish debugging at
*/
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3616kb
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: 0ms
memory: 3532kb
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 No Yes + -23/240 + 100/240 No Yes + 89/240 + 100/240
result:
wrong answer ans finds the answer, but out doesn't (test case 3)