QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#417747#5114. Cells ColoringgankingWA 2ms3628kbC++201.4kb2024-05-22 21:36:422024-05-22 21:36:42

Judging History

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

  • [2024-05-22 21:36:42]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3628kb
  • [2024-05-22 21:36:42]
  • 提交

answer

#include<bits/stdc++.h>
#define fo(i,a,b) for (int (i)=(a);(i)<=(b);(i)++)
#define fd(i,b,a) for (int (i)=(b);(i)>=(a);(i)--)
#define mk(x,y) make_pair((x),(y))
#define ll long long
using namespace std;
const int N = 1e6 + 100;


int n, m, c, d;
char a[260][260];
int x[260], y[260];



int main() {
    #ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, m, c, d;
    cin >> n >> m >> c >> d;
    for (int i = 0;i < n;i++)
    {
        for (int j = 0;j < m;j++)
        {
            cin >> a[i][j];
            if (a[i][j] == '.')
            {
                x[i]++;
                y[j]++;
            }
        }
    }
    ll ans, tmp;
    ll answer = 1e18;
    
    for (int i = 0;i <= max(n, m);i++)
    {
        ans = 0;
        tmp = i * c;
        for (int j = 0;j < n;j++)
        {
            //cout << x[j] << " ";
            tmp += max(0, x[j] - i) * d;
        }
        //cout << tmp << '\n';
        ans = max(ans, tmp);

        tmp = i * c;
        for (int j = 0;j < m;j++)
        {
            tmp += max(0, y[j] - i) * d;
            //cout << y[j] << " ";
        }
        //cout << tmp << '\n';
        ans = max(ans, tmp);
        answer = min(answer, ans);
    }
    cout << answer;
    return 0;
}

详细

Test #1:

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

input:

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

output:

4

result:

ok 1 number(s): "4"

Test #2:

score: 0
Accepted
time: 1ms
memory: 3628kb

input:

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

output:

2

result:

ok 1 number(s): "2"

Test #3:

score: -100
Wrong Answer
time: 2ms
memory: 3508kb

input:

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

output:

0

result:

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