QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#68319#4788. GravityA_zjzjWA 81ms38160kbC++14767b2022-12-15 18:49:002022-12-15 18:49:02

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-12-15 18:49:02]
  • 评测
  • 测评结果:WA
  • 用时:81ms
  • 内存:38160kb
  • [2022-12-15 18:49:00]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;using ll=long long;const int N=2e3+10;
int n,m,k,d[N][N],f[N][N];char a[N][N],b[N][N];
int main(){
	scanf("%d%d",&n,&m);for(int i=1;i<=n;i++)scanf("%s",a[i]+1);for(int j=1;j<=m;j++)d[n+1][j]=n+1;
	for(int i=n;i>=1;i--)for(int j=1;j<=m;j++)if(a[i][j]=='#')d[i][j]=i;else d[i][j]=d[i+1][j];for(int i=n;i>=1;i--){
		for(int j=1;j<=m;j++)if(a[i][j]=='#')f[i][j]=f[d[i+1][j]][j]+1;
		for(int j=1;j<=m;j++)if(a[i][j]=='#')f[i][j]=max(f[i][j],f[i][j-1]);
		for(int j=m;j>=1;j--)if(a[i][j]=='#')f[i][j]=max(f[i][j],f[i][j+1]);
	}for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)b[i][j]='.';
	for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)if(a[i][j]=='#')b[f[i][j]][j]='#';
	for(int i=n;i>=1;i--)printf("%s\n",b[i]+1);return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 3ms
memory: 7632kb

input:

10 10
..........
..######..
..#....#..
..#.#..#..
..#..#.#..
..#....#..
..######..
..........
..#....#..
.......#..


output:

..........
..........
..######..
..#....#..
..#....#..
..#....#..
..#.##.#..
..######..
.......#..
..#....#..

result:

ok 10 lines

Test #2:

score: -100
Wrong Answer
time: 81ms
memory: 38160kb

input:

1583 1799
#..###..##..#.####.##.##.###..#.....##..#.#.#.#......#.....##..#.##...#.#....#..##.###...#...##.###.#.....#.##.###...#..##.#...###..#.###.#...###..#.......#...#....#.#..#...##........#.#..#..##.....###...#..#.####..####...#..##......#........#..#.##.##..#..#....##.##.##..#..##.....###....#...

output:

...............................................................................................................................................................................................................................................................................................................

result:

wrong answer 283rd lines differ - expected: '................................................................', found: '................................................................'