QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#676482#5114. Cells Coloringstudy_to_deathWA 3ms3968kbC++141.5kb2024-10-25 21:46:252024-10-25 21:46:25

Judging History

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

  • [2024-10-25 21:46:25]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3968kb
  • [2024-10-25 21:46:25]
  • 提交

answer

#include <bits/stdc++.h>
#define ll long long
#define int long long

using namespace std;

int n, m, c, d, mx, ans, cnt;
char s[255][255];
int row[300], col[300];

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++)
    {
        set<int> r, cc;
        int tmp = 0;
        for (int i = 1; i <= n; i++)
            if (row[i] > k)
            {
                tmp += row[i] - k;
                r.insert(i);
            }
        for (int i = 1; i <= m; i++)
            if (col[i] > k)
            {
                tmp += col[i] - k;
                cc.insert(i);
            }
        tmp -= min(r.size(), cc.size());
        // tmp = max(tmp, 0ll);
        // cout << k << " " << tmp << "****" << endl;
        ans = min(ans, c * k + d * tmp);
        // cout << ans << "////" << endl;
    }
    cout << ans << endl;
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3648kb

input:

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

output:

4

result:

ok 1 number(s): "4"

Test #2:

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

input:

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

output:

2

result:

ok 1 number(s): "2"

Test #3:

score: -100
Wrong Answer
time: 3ms
memory: 3968kb

input:

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

output:

112704535794

result:

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