QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#356050 | #8236. Snake Move | USTC_fish_touching_team# | WA | 862ms | 366704kb | C++14 | 964b | 2024-03-17 15:08:51 | 2024-03-17 15:08:52 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=3005;
int n,m,k;
int a[N][N];
int x[N*N],y[N*N];
int f[N][N],lim[N][N];
int qx[4*N*N],qy[4*N*N],l,r;
char s[N];
void gx(int x,int y,int tx,int ty){
if(tx>n||ty>m||tx<1||ty<1)return ;
int w=lim[tx][ty];
if(w<f[x][y]+1)w=f[x][y]+1;
if(f[tx][ty]>w)f[tx][ty]=w,
qx[++r]=tx,qy[r]=ty;
}
int main(){
cin>>n>>m>>k;
memset(f,63,sizeof(f));
for(int i=1;i<=k;i++){
scanf("%d%d",&x[i],&y[i]);
lim[x[i]][y[i]]=k-i+1;
}
for(int i=1;i<=n;i++){
scanf("%s",s+1);
for(int j=1;j<=m;j++){
if(s[j]=='#')lim[i][j]=1e9;
}
}
qx[l=r=1]=x[1],qy[1]=y[1];
f[x[1]][y[1]]=0;
while(l<=r){
int x=qx[l],y=qy[l];
l++;
gx(x,y,x+1,y);
gx(x,y,x,y+1);
gx(x,y,x-1,y);
gx(x,y,x,y-1);
}
unsigned long long ans=0;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(f[i][j]>1e8)f[i][j]=0;
ans=ans+1ll*f[i][j]*f[i][j];
}
}
printf("%llu",ans);
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 39036kb
input:
4 5 5 3 5 3 4 3 3 3 2 4 2 ..... ..... ..... .....
output:
293
result:
ok single line: '293'
Test #2:
score: 0
Accepted
time: 0ms
memory: 39212kb
input:
2 2 4 1 1 1 2 2 2 2 1 .. ..
output:
14
result:
ok single line: '14'
Test #3:
score: 0
Accepted
time: 0ms
memory: 39192kb
input:
5 5 3 1 2 1 1 2 1 ..... .###. .#.#. .###. .....
output:
407
result:
ok single line: '407'
Test #4:
score: 0
Accepted
time: 168ms
memory: 146116kb
input:
3000 2900 1 1882 526 ........................................................................................................#................................................................................................................................................................#................
output:
35141960580077
result:
ok single line: '35141960580077'
Test #5:
score: -100
Wrong Answer
time: 862ms
memory: 366704kb
input:
2900 3000 1 1333 1773 .....#....#......#.#..#...#.....#.#.#.#....#...###.#..#.....##....####..#......#.......######.#........#..#......#...###.#.#..#.....#.#........##..#..#.#..#.###.#.#...#..#.##..#...#....#..#.##..#......#.######............#.#...#......#......#..#.#.#.#...#...#..##........#.###.....
output:
18017673555224
result:
wrong answer 1st lines differ - expected: '17464052497724', found: '18017673555224'