QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#782618 | #5114. Cells Coloring | guodong# | WA | 46ms | 4176kb | C++17 | 2.0kb | 2024-11-25 20:41:50 | 2024-11-25 20:41:51 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
#define For(i,a,b) for(int i = a; i <= b; ++i)
int Map[300][300];
int n,m,c,d;
int Row[300],Col[300];
int maxx = 0;
int cnt = 0;
int value(){
maxx = 0;
For(i,1,n) maxx = max(maxx,Row[i]);
For(j,1,m) maxx = max(maxx,Col[j]);
return maxx * c;
}
void del(int x,int y){
Row[x] --;
Col[y] --;
Map[x][y] = 0;
value();
--cnt;
}
signed main(){
#ifdef NICEGUODONG
freopen("data.in","r",stdin);
#endif
ios::sync_with_stdio(false);
cin >> n >> m >> c >>d;
For(i,1,n) For(j,1,m){
char tmp;
cin >> tmp;
if(tmp == '.'){
Map[i][j] = 1;
++cnt;
Row[i]++;
Col[j]++;
}
}
int ans = value();
int num = 0;
do{
int flag = 0;
++num;
For(i,1,n){
if(flag) break;
if(Row[i] == maxx){
flag = 1;
int maxv = 0,pos = -1;
For(j,1,m){
if(Map[i][j] == 0) continue;
if(Col[j] >= maxv){
pos =j;
maxv = Col[j];
}
}
del(i,pos);
}
}
if(!flag){
For(j,1,m){
if(flag) break;
if(Col[j] == maxx){
flag = 1;
int maxv = 0,pos = -1;
For(i,1,n){
if(Map[i][j] == 0) continue;
if(Row[i] >= maxv){
pos = i;
maxv = Row[i];
}
}
del(pos,j);
}
}
}
ans = min(ans,maxx * c + num * d);
}while(cnt != 0);
cout << ans << '\n';
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3656kb
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: 0
Accepted
time: 25ms
memory: 4172kb
input:
250 250 965680874 9042302 ..**.*****..**..**.*****..***..***.**......*.***.*...***.*....*.**.*.**.*.*.****...*.******.***.************....**.*..*..***.*******.*.***.*..**..****.**.*.*..***.****..**.....***.....*.****...*...*.***..****..**.*.*******..*.*******.*.*.*.****.*.*** ....**.*******.*.******...
output:
109972100048
result:
ok 1 number(s): "109972100048"
Test #4:
score: 0
Accepted
time: 36ms
memory: 4168kb
input:
250 250 62722280 506434 *.**.***.*.*....*....*...**.*..**..****.*.*..*.*.*..*.....**..*.*.*.*****.*.**..*.**....***..*..*.*.*.**.*..*..*.**..*...**....**..*.*.***.*****.*****.***..**.***.****....*.*.**.**.*...****....*..*.**.**********.......********...***.**..*.....**.*..* .*..********..*...*..****...
output:
8437726048
result:
ok 1 number(s): "8437726048"
Test #5:
score: -100
Wrong Answer
time: 46ms
memory: 4176kb
input:
250 250 85956327 344333 ..*.............*...*.....*...*..........*.........*...*.......*..***......*.*........*.*........*........*..*..*.............*.*........*....*..*................***...................*..*.............*..*.....*..**..............*..*......*.....*..** .........*......*.*.........
output:
18268375460
result:
wrong answer 1st numbers differ - expected: '18268031127', found: '18268375460'