QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#629892 | #5140. Frozen Scoreboard | kuguadawang | WA | 5ms | 3700kb | C++23 | 3.5kb | 2024-10-11 15:24:10 | 2024-10-11 15:24:11 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N = 20;
int t, n;
char a[N];
int x[N], y[N];
pii s[1 << N];
//基础罚时以及剩下多少次可以罚时
int lowbit(int x) {
int s = 0;
while (x) {
s++;
x -= (x & -x);
}
return s;
}
int sss = 0;
void solve()
{
sss++;
int s1, s2;
cin >> s1 >> s2;
int sumf = 0;
int sumd = 0;
priority_queue<int> mx;
priority_queue<int, vector<int>, greater<int>> mi;
for (int i = 0; i < n; i++) {
cin>>a[i];
if (a[i]=='+') {
int cs=0,sj=0,dd=0;
string s;
cin>>s;
for (int j=0; j<s.size(); j++) {
if (s[j]=='/') {
dd=j;
break;
}
cs=cs*10+s[j]-'0';
}
for (int j=dd+1; j<s.size(); j++) {
sj=sj*10+s[j]-'0';
}
x[i]=cs;
y[i]=sj;
sumd ++;
sumf += x[i] * 20 - 20 + y[i];
} else if (a[i]=='-') {
cin>>x[i];
} else if (a[i]=='.') {
continue;
} else {
cin>>x[i]>>y[i];
}
}
int need = s1 - sumd;
for (int i = 0; i < (1 << n); i++) {
s[i] = {0, 0};
if (lowbit(i) != need) {
continue ;
}
bool use = 1;
for (int j = 0; j < n; j++) {
if ((i >> j) & 1) {
if (a[j] != '?') {
use = 0;
break;
}
}
}
if (!use) {
continue ;
}
for (int j = 0; j < n; j++) {
if ((i >> j) & 1) {
s[i].first += (y[j] - x[j]) * 20 + 240;
s[i].second += y[j] * 20 + 299;
}
}
if (sumf + s[i].first <= s2 && sumf + s[i].second >= s2) {
cout << "Yes\n";
//减去基础罚时
ll d = s2 - sumf;
d -= s[i].first;
for (int j = 0; j < n; j++) {
if ((i >> j) & 1) {
a[j] = '+';
} else {
if (a[j] == '?') {
a[j] = '-';
x[j] = y[j];
}
}
}
//现在x[i]存的是之前提交过几次,y[i]存的是总共提交
for (int j = 0; j < n; j++) {
if ((i >> j) & 1) {
x[j] = y[j] - x[j] + 1;
while (d >= 20 && x[j] < y[j]) {
d -= 20;
x[j]++;
}
int mx = min(d, 1ll * 59);
y[j] = 240 + mx;
d -= mx;
}
}
int f = 0;
sumf = 0;
for (int j = 0; j < n; j++) {
if (a[j] == '?')
a[j] = '-';
cout << a[j] << ' ';
if (a[j] == '+') {
cout << x[j] << '/' << y[j] << '\n';
sumf += x[j] * 20 - 20 + y[j];
} else if (a[j] == '-') {
cout << x[j] << '\n';
} else {
cout << '\n';
}
}
while (sumf != s2) {
}
return ;
}
}
cout << "No\n";
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cin >> t >> n;
while(t--)
solve();
return 0;
}
/*
6700
*/
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3624kb
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: 3612kb
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: 5ms
memory: 3700kb
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 + 3/278 - 5 + 3/240 - 5 + 1/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 -...
result:
wrong answer wrong total time (test case 13)