QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#208235#5114. Cells ColoringFYBGCWA 0ms3660kbC++201.1kb2023-10-09 11:24:002023-10-09 11:24:01

Judging History

你现在查看的是最新测评结果

  • [2023-10-09 11:24:01]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3660kb
  • [2023-10-09 11:24:00]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
const int N = 300;
ll a[N];
ll b[N];
void solve()
{
    int n, m, c, d;
    cin >> n >> m >> c >> d;
    string s[n + 10];
    // vector<int> a(n + 1);
    // vector<int> b(n + 1);

    for (int i = 0; i < n; i++)
        cin >> s[i];
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            if (s[i][j] == '.')
            {
                a[i]++;
                b[j]++;
            }
        }
    }
    int k = max(*max_element(a, a + n), *max_element(b, b + m));
    int ans = c * k;
    for (int i = k - 1; i >= 0; i--)
    {
        int cnt1 = 0;
        for (int j = 0; j < n; j++)
            cnt1 += max(0LL, a[j] - i);
        int cnt2 = 0;
        for (int j = 0; j < m; j++)
            cnt2 += max(0LL, b[j] - i);
        ans = min(ans, max(cnt2, cnt1) * d + c * i);
    }
    cout << ans << endl;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3612kb

input:

3 4 2 1
.***
*..*
**..

output:

4

result:

ok 1 number(s): "4"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3644kb

input:

3 4 1 2
.***
*..*
**..

output:

2

result:

ok 1 number(s): "2"

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3660kb

input:

250 250 965680874 9042302
..**.*****..**..**.*****..***..***.**......*.***.*...***.*....*.**.*.**.*.*.****...*.******.***.************....**.*..*..***.*******.*.***.*..**..****.**.*.*..***.****..**.....***.....*.****...*...*.***..****..**.*.*******..*.*******.*.*.*.****.*.***
....**.*******.*.******...

output:

-2084300836

result:

wrong answer 1st numbers differ - expected: '109972100048', found: '-2084300836'