QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#72272#4788. GravitylmeowdnWA 102ms15352kbC++141.4kb2023-01-15 11:47:402023-01-15 11:48:15

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-01-15 11:48:15]
  • 评测
  • 测评结果:WA
  • 用时:102ms
  • 内存:15352kb
  • [2023-01-15 11:47:40]
  • 提交

answer

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define fi first
#define se second
#define eb emplace_back
#define bp __builtin_parity
#define y1 yyl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vp;
typedef bitset<1009> bset;

int read() {
	int x=0,w=1; char c=getchar();
	while(!isdigit(c)) {if(c=='-') w=-1; c=getchar();}
	while(isdigit(c)) {x=x*10+c-'0'; c=getchar();}
	return x*w;
}

const int N=2002,inf=0x3f3f3f3f;
int n,m,tot;
short d[N][N];
char s[N][N];
deque<pair<short,short>>q;

void upd(int x1,int y1,int x2,int y2) {
	if(!y2||y2>m) return;
	int w=1-(s[x2][y2]=='#');
	if(x1==x2&&(s[x1][y1]=='.'||s[x1][y2]=='.')) return;
	if(d[x1][y1]+w<d[x2][y2]) {
		d[x2][y2]=d[x1][y1]+w;
		if(!w) q.push_front(pii(x2,y2));
		else q.push_back(pii(x2,y2));
	}
}

signed main() {
	n=read(), m=read();
	rep(i,1,n) scanf("%s",s[i]+1);
	rep(j,1,m) s[n+1][j]='#';
	memset(d,0x3f,sizeof(d));
	q.push_front(pii(n+1,1)); d[n+1][1]=0;
	while(!q.empty()) {
		int x=q.front().fi, y=q.front().se; q.pop_front();
		if(x>1) upd(x,y,x-1,y); upd(x,y,x,y-1), upd(x,y,x,y+1);
	}
	per(i,n,1) rep(j,1,m) {
		if(s[i][j]=='#') s[i][j]='.', s[i+d[i][j]][j]='#';
	}
	rep(i,1,n) {
		rep(j,1,m) putchar(s[i][j]);
		puts("");
	}
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 12644kb

input:

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


output:

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

result:

ok 10 lines

Test #2:

score: -100
Wrong Answer
time: 102ms
memory: 15352kb

input:

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

output:

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

result:

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