QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#676529 | #5114. Cells Coloring | study_to_death | WA | 1ms | 3772kb | C++14 | 1.8kb | 2024-10-25 21:57:06 | 2024-10-25 21:57:07 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
#define int long long
using namespace std;
const int N = 255 * 255;
int n, m, c, d, mx, ans, cnt;
char s[255][255];
int row[300], col[300];
int x[N], y[N];
signed main()
{
cin >> n >> m >> c >> d;
for (int i = 1; i <= n; i++)
{
scanf("%s", s[i] + 1);
}
for (int i = 1; i <= n; i++)
{
int num = 0;
for (int j = 1; j <= m; j++)
{
if (s[i][j] == '*')
continue;
cnt++;
num++;
row[i]++;
}
mx = max(mx, num);
}
for (int i = 1; i <= m; i++)
{
int num = 0;
for (int j = 1; j <= n; j++)
{
if (s[j][i] == '*')
continue;
num++;
col[i]++;
}
mx = max(mx, num);
}
ans = min(cnt * d, mx * c);
// cout << mx << endl;
for (int k = 1; k <= mx; k++)
{
int r = 0, cc = 0;
int tmp = 0;
for (int i = 1; i <= n; i++)
if (row[i] > k)
{
tmp += row[i] - k;
x[++r] = i;
}
for (int i = 1; i <= m; i++)
if (col[i] > k)
{
tmp += col[i] - k;
y[++cc] = i;
}
for (int i = 1; i <= r; i++)
{
for (int j = 1; j <= cc; j++)
{
if (s[i][j] == '.')
{
i++;
tmp--;
}
}
}
// tmp = max(tmp, 0ll);
// cout << k << " " << tmp << "****" << endl;
ans = min(ans, c * k + d * tmp);
// cout << ans << "////" << endl;
}
cout << ans << endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3772kb
input:
3 4 2 1 .*** *..* **..
output:
4
result:
ok 1 number(s): "4"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3700kb
input:
3 4 1 2 .*** *..* **..
output:
2
result:
ok 1 number(s): "2"
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 3676kb
input:
250 250 965680874 9042302 ..**.*****..**..**.*****..***..***.**......*.***.*...***.*....*.**.*.**.*.*.****...*.******.***.************....**.*..*..***.*******.*.***.*..**..****.**.*.*..***.****..**.....***.....*.****...*...*.***..****..**.*.*******..*.*******.*.*.*.****.*.*** ....**.*******.*.******...
output:
112532732056
result:
wrong answer 1st numbers differ - expected: '109972100048', found: '112532732056'