QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#698704#5114. Cells Coloringstudy_to_deathWA 1ms3856kbC++141.8kb2024-11-01 21:27:532024-11-01 21:27:54

Judging History

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

  • [2024-11-01 21:27:54]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3856kb
  • [2024-11-01 21:27:53]
  • 提交

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: 3820kb

input:

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

output:

4

result:

ok 1 number(s): "4"

Test #2:

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

input:

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

output:

2

result:

ok 1 number(s): "2"

Test #3:

score: -100
Wrong Answer
time: 1ms
memory: 3856kb

input:

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

output:

112532732056

result:

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