QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#252275#6739. Teleportucup-team191#WA 31ms107216kbC++141.4kb2023-11-15 17:31:002023-11-15 17:31:00

Judging History

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

  • [2023-11-15 17:31:00]
  • 评测
  • 测评结果:WA
  • 用时:31ms
  • 内存:107216kb
  • [2023-11-15 17:31:00]
  • 提交

answer

#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
using ll=long long;
using pii=pair<int,int>;
using vi=vector<int>;
using vl=vector<ll>;
#define pb push_back
#define all(a) begin(a),end(a)

const int N=5010,MOD=1e9+7;
const char en='\n';
const ll LLINF=1ll<<60;

int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int n,k;
string h[N];
bool bio[N][N];
int dis[N][N];

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	memset(dis,63,sizeof(dis));
	cin>>n>>k;
	for (int i=0;i<n;++i) cin>>h[i];
	queue<pii> q;
	q.push({0,0});
	dis[0][0]=0;
	while (q.size())
	{
		int i=q.front().x,j=q.front().y,d=dis[i][j];
		q.pop();
		if (i==n-1 && j==n-1)
		{
			cout<<d<<en;
			exit(0);
		}
		for (int u=0;u<4;++u)
		{
			int i1=i+dx[u],j1=j+dy[u];
			if (i1<0 || j1<0 || i1>=n || j1>=n || bio[i1][j1]) continue;
			if (h[i1][j1]=='*') continue;
			bio[i1][j1]=1;
			dis[i1][j1]=d+1;
			q.push({i1,j1});
		}
		for (int u=1;u<=k/2;++u)
		{
			int i1=i+u,j1=j+u;
			if (i1<0 || j1<0 || i1>=n || j1>=n || bio[i1][j1]) break;
			if (h[i1][j1]=='*') continue;
			bio[i1][j1]=1;
			dis[i1][j1]=d+1;
			q.push({i1,j1});
		}
		for (int u=0;u<=(k-1)/2;++u)
		{
			int i1=j+u+1,j1=i+u;
			if (i1<0 || j1<0 || i1>=n || j1>=n || bio[i1][j1]) break;
			if (h[i1][j1]=='*') continue;
			bio[i1][j1]=1;
			dis[i1][j1]=d+1;
			q.push({i1,j1});
		}
	}
	cout<<-1<<en;
}

详细

Test #1:

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

input:

3 2
.*.
.*.
...

output:

3

result:

ok 1 number(s): "3"

Test #2:

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

input:

3 3
.*.
.*.
...

output:

2

result:

ok 1 number(s): "2"

Test #3:

score: -100
Wrong Answer
time: 31ms
memory: 107216kb

input:

961 4
...*.*..*.....*.*..*..*..*.*.*.*.....*.....*....*..*...*....*.........*....*....*...*......*..*..*...*..*...*.....*...*...*.*.*.........**..**.......*.......*...*...*.*.*........*....*..*..*...*.....*.*......**.**..**...*..*.**.....*....*.*.*..*..*..*.*..*.*..*......*..*..*.*......*...*.*...*....

output:

547

result:

wrong answer 1st numbers differ - expected: '540', found: '547'