QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#621296 | #5140. Frozen Scoreboard | yzj123 | WA | 2ms | 3844kb | C++20 | 3.2kb | 2024-10-08 12:16:38 | 2024-10-08 12:16:39 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int read()
{
int res = 0, bj = 1;
char ch = getchar();
while (ch < '0' || ch > '9')
{
if (ch == '-') bj = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9')
{
res = res * 10 + ch - '0';
ch = getchar();
}
return res * bj;
}
const int MAXN = 1005;
int tt, m; //人数和题目数
int a, b; //过题数和总罚时
int ac[15]; //-1没做, 0没过, 1过了, 2问号
int sm[15], tim[15]; //
char ch[10005];
vector<int> pb;
void solve()
{
a = read(), b = read();
for (int i = 1; i <= m; i++)
{
scanf("%s", ch + 1);
if (ch[1] == '+')
{
ac[i] = 1;
scanf("%s", ch + 1);
int x = 0, y = 0, len = strlen(ch + 1);
int j;
for (j = 1; j <= len; j++)
{
if (ch[j] != '/') x = x * 10 + ch[j] - '0';
else break;
}
j++;
for (; j <= len; j++) y = y * 10 + ch[j] - '0';
a--;
b -= (x - 1) * 20 + y;
sm[i] = x;
tim[i] = y;
}
else if (ch[1] == '?')
{
ac[i] = 2;
pb.push_back(i);
sm[i] = read();
tim[i] = read() - sm[i];
}
else if (ch[1] == '-')
{
ac[i] = 0;
sm[i] = read();
}
else ac[i] = -1;
}
int fl = 0;
int tot = pb.size();
int S = (1 << tot) - 1;
int ltim = 240 * a, rtim = 299 * a;
if (a != 0)
{
for (int i = 0; i <= S; i++)
{
int res = b; //剩余罚时
int num = 0; //可以用的20的数量
int k = 0; //过题数量
for (int j = 0; j < tot; j++)
if (i & (1 << j))
{
res -= tim[pb[j]] * 20;
num += sm[pb[j]] - 1;
k++;
}
// cout << "i:" << i << " " << res << " " << num << " " << k << "\n";
if (k != a || res < ltim) continue;
int tmp = 0;
if (res > rtim) tmp = (res - rtim - 1) / 20 + 1;
// cout << "tmp:" << tmp << "\n";
if (tmp > num) continue;
else
{
res -= tmp * 20;
for (int j = 0; j < tot; j++)
if (i & (1 << j))
{
if (tmp >= sm[pb[j]] - 1) //此时sm不变
{
sm[pb[j]] += tim[pb[j]];
tmp -= sm[pb[j]] - 1;
}
else
{
sm[pb[j]] = tmp + 1 + tim[pb[j]];
tmp = 0;
}
}
}
int avg = res / a;
for (int j = 0; j < tot; j++)
if (i & (1 << j))
{
ac[pb[j]] = 1;
tim[pb[j]] = avg;
res -= avg;
}
if (res != 0)
{
for (int j = 0; j < tot; j++)
if (i & (1 << j) && res != 0)
{
tim[pb[j]]++;
res--;
// tim[pb[j]] += res;
// break;
}
}
for (int j = 0; j < tot; j++)
if ((i & (1 << j)) == 0)
{
ac[pb[j]] = 0;
sm[pb[j]] += tim[pb[j]];
}
fl = 1;
break;
}
}
else
{
for (int i = 1; i <= m; i++)
if (ac[i] == 2)
{
ac[i] = 0;
sm[i] += tim[i];
}
}
if (fl == 1 || (a == 0 && b == 0))
{
cout << "Yes\n";
for (int i = 1; i <= m; i++)
{
if (ac[i] == -1) cout << '.' << "\n";
else if (ac[i] == 1) cout << "+ " << sm[i] << '/' << tim[i] << "\n";
else cout << "- " << sm[i] << "\n";
}
}
else cout << "No\n";
pb.clear();
for (int i = 1; i <= m; i++) ac[i] = sm[i] = tim[i] = 0;
}
int main()
{
tt = read(), m = read();
while (tt--) solve();
return 0;
}
/*
1 4
2 480
? 10 10
? 10 10
- 1
- 10
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3844kb
input:
1 13 7 951 + 1/6 ? 3 4 + 4/183 - 2 + 3/217 . . . + 2/29 + 1/91 . + 1/22 .
output:
Yes + 1/6 + 2/263 + 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: 3744kb
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 + 87/280 - 100
result:
ok ok (6 test cases)
Test #3:
score: -100
Wrong Answer
time: 2ms
memory: 3844kb
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 + 2/260 - 5 + 3/259 - 5 + -1/259 - 3 - 5 + 1/165 - 6 - 5 Yes - 2 - 9 . - 1 - 7 - 6 + 4/179 - 2 + 4/271 . - 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 + 4/2...
result:
wrong answer Token "-1/259" doesn't correspond to pattern "[0-9]{1,3}/[0-9]{1,3}" (test case 1)