QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#528093 | #5141. Identical Parity | syss | WA | 0ms | 3820kb | C++17 | 3.1kb | 2024-08-23 08:15:58 | 2024-08-23 08:15:58 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
struct Info {
char op[2];
int x, y;
};
int main() {
int n, m;
scanf("%d%d", &n, &m);
while (n--) {
int Solve, Time;
scanf("%d%d", &Solve, &Time);
int sum = 0, sumtime = 0;
vector<int> p;
vector<Info> info(m);
int t = 0;
for (auto &[op, x, y] : info) {
scanf ("%s", op);
if (op[0] == '+') {
scanf("%d/%d", &x, &y);
sum++;
sumtime += (x - 1) * 20 + y;
} else if (op[0] == '-') {
scanf("%d", &x);
} else if (op[0] == '?') {
p.push_back(t);
scanf("%d%d", &x, &y);
}
t++;
}
if (sumtime > Time || sum > Solve) {
printf ("No\n");
continue;
}
bool ok = false;
int siz = p.size();
for (int i = 0; i < 1 << siz; i++) {
int tot = 0;
for (int j = 0; j < siz; j++) {
if (i >> j & 1) {
tot ++;
}
}
if (tot != Solve - sum) continue;
int now = sumtime;
int cnt = 0;
for (int j = 0; j < siz; j++) {
if (i >> j & 1) {
auto [op, x, y] = info[p[j]];
now += 239 + (y - x) * 20;
cnt += x;
}
}
now += tot;
if (Time < now) {
continue;
}
if (Time > now + (cnt-tot) * 20 + 59 * tot) {
continue;
}
for (int j = 0; j < siz; j++) {
auto &[op, x, y] = info[p[j]];
if (i >> j & 1) {
op[0] = '+';
int z = 0;
if (Time - now >= (x - 1) * 20) {
now += (x - 1) * 20;
x=y;
} else {
z = (Time - now) / 20;
now += z * 20;
x = (y - x) + z + 1;
}
if (Time - now >= 59) {
now += 59;
y = 299;
} else {
y = (Time - now) + 240;
now = Time;
}
} else {
op[0] = '-';
x = y;
}
}
ok = true;
break;
}
if (ok) {
printf("Yes\n");
for (auto &[op, x, y] : info) {
if (op[0] == '+') {
printf("+ %d/%d\n", x, y);
} else if (op[0] == '-') {
printf("- %d\n", x);
} else {
printf(".\n");
}
}
} else {
printf("No\n");
}
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3820kb
input:
3 3 1 4 2 5 3
output:
No No No
result:
wrong answer expected YES, found NO [2nd token]