QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#676529#5114. Cells Coloringstudy_to_deathWA 1ms3772kbC++141.8kb2024-10-25 21:57:062024-10-25 21:57:07

Judging History

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

  • [2024-10-25 21:57:07]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3772kb
  • [2024-10-25 21:57:06]
  • 提交

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;
}

详细

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'