QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#548131#8236. Snake MoveWhaleAtColaWA 276ms147892kbC++171.8kb2024-09-05 15:44:342024-09-05 15:44:34

Judging History

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

  • [2024-09-05 15:44:34]
  • 评测
  • 测评结果:WA
  • 用时:276ms
  • 内存:147892kb
  • [2024-09-05 15:44:34]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define debug(...) fprintf(stderr,__VA_ARGS__)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
inline ll read(){
	ll x=0;bool w=0;char c=getchar();
	while(c>'9'||c<'0') w|=c=='-',c=getchar();
	while(c>='0'&&c<='9') x=x*10+(c-'0'),c=getchar();
	return w?-x:x;
}

const int inf=0x3f3f3f3f;
inline int crd(){
	char c=getchar();
	while(c!='#'&&c!='.') c=getchar();
	return c=='#'?inf:0;
}

const int N=3030,L=101010;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
int ex[L],ey[L],g[N][N],f[N][N],qx[N*N],qy[N*N],ok[L];
inline void rmain(){
	int n=read(),m=read(),l=read(),ql,qr,px,py,tx,ty,tt;
	for(int i=1;i<=l;++i) ex[i]=read(),ey[i]=read();
	memset(g,0x3f,sizeof g);
	memset(f,0x3f,sizeof f);
	for(int i=1;i<=n;++i) for(int j=1;j<=m;++j) g[i][j]=crd();
	for(int i=1;i<=l;++i) g[ex[i]][ey[i]]=l-i+1;
//	for(int i=1;i<=n;++i) for(int j=1;j<=m;++j) debug("%2d%c",g[i][j]," \n"[j==m]);
	qx[ql=qr=1]=ex[1],qy[1]=ey[1],f[ex[1]][ey[1]]=0,tt=0;
	while(ql<=qr||tt<=l){
		if(ql<=qr){
			px=qx[ql],py=qy[ql++];
			if(tt<=l&&ok[tt]==1) qx[++qr]=ex[tt],qy[qr]=ey[tt],ok[tt]=2;
		}else{
			while(tt<=l&&ok[tt]!=1) ++tt;
			if(tt>l) break;
			px=ex[tt],py=ey[tt],ok[tt]=2;
		}
		tt=f[px][py]+1;
//		debug("px:%d py:%d\n",px,py);
		for(int k=0;k<4;++k){
			tx=px+dx[k],ty=py+dy[k];
			if(f[tx][ty]>tt){
				if(g[tx][ty]<=tt) qx[++qr]=tx,qy[qr]=ty,f[tx][ty]=tt;
				else if(g[tx][ty]!=inf) ok[l-g[tx][ty]+1]=1,f[tx][ty]=g[tx][ty];
			}
		}
	}
//	for(int i=1;i<=n;++i) for(int j=1;j<=m;++j) debug("%2d%c",f[i][j]," \n"[j==m]);
	ull ans=0;
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
			if(f[i][j]!=inf) ans+=((ull)f[i][j])*f[i][j];
	printf("%llu\n",ans);
}

signed main(){
//	int T=read();while(T--)
	rmain();
	return 0;
}


詳細信息

Test #1:

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

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: 4ms
memory: 79992kb

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: 3ms
memory: 78752kb

input:

5 5 3
1 2
1 1
2 1
.....
.###.
.#.#.
.###.
.....

output:

407

result:

ok single line: '407'

Test #4:

score: 0
Accepted
time: 104ms
memory: 147892kb

input:

3000 2900 1
1882 526
........................................................................................................#................................................................................................................................................................#................

output:

35141960580077

result:

ok single line: '35141960580077'

Test #5:

score: 0
Accepted
time: 276ms
memory: 126800kb

input:

2900 3000 1
1333 1773
.....#....#......#.#..#...#.....#.#.#.#....#...###.#..#.....##....####..#......#.......######.#........#..#......#...###.#.#..#.....#.#........##..#..#.#..#.###.#.#...#..#.##..#...#....#..#.##..#......#.######............#.#...#......#......#..#.#.#.#...#...#..##........#.###.....

output:

17464052497724

result:

ok single line: '17464052497724'

Test #6:

score: 0
Accepted
time: 78ms
memory: 78460kb

input:

3000 3000 1
2755 225
##..#.##.....####..#...###.#.##.#.##.#......###.#####..#..####....#.#.####..##..##.#...#...##..#.#.##..#....##.#...#.....##.#...##.##.##..##..#######.####.####......##.##.#....#..#.....#..##.#.#...#.####..##.#..#...###..###.#.#...##.#.....###.####......##...#...#....#.#...#.#.#....

output:

255915

result:

ok single line: '255915'

Test #7:

score: 0
Accepted
time: 55ms
memory: 78052kb

input:

3000 2900 1
878 738
#.##.##..##.#.#.###.#...###.####.#.###.####.##.#.#####.#.####..#.#.###.###..####.####...###..####.########..##..#####.#....#####.#.#########..#.###.##.##.#####.#####.#.##..###..##.#####.#.############..##.###.##.##..########.#.###..###...######.####...#######.###.###..####.######...

output:

1

result:

ok single line: '1'

Test #8:

score: 0
Accepted
time: 139ms
memory: 147424kb

input:

2900 3000 10
2883 1758
2883 1759
2883 1760
2883 1761
2883 1762
2884 1762
2884 1763
2883 1763
2882 1763
2882 1764
........................................................#............................#........................................................................................................

output:

49803365625286

result:

ok single line: '49803365625286'

Test #9:

score: 0
Accepted
time: 275ms
memory: 128820kb

input:

3000 3000 10
2015 1932
2015 1931
2015 1930
2015 1929
2016 1929
2017 1929
2018 1929
2018 1928
2018 1927
2017 1927
#...#...#..#.........#.......#####....#...###..#..###..###....##.....#..#..#...#.....##...##.#..#..##.###.........##.....#....#..##.##.#.#.##.#.#.#.....#....##.##.#..##....#....#...#.#......

output:

22509095749285

result:

ok single line: '22509095749285'

Test #10:

score: 0
Accepted
time: 73ms
memory: 79460kb

input:

3000 2900 10
326 1781
325 1781
325 1782
325 1783
325 1784
324 1784
324 1783
323 1783
323 1782
324 1782
##.#....#.###.######..#.#.....##.#.##..####.####.##..#..#.###.#####....##.#.##.#..###..##.###.##.#####.###..##.#..##..##.#..##.#.#.##...##..#.##.##........#..#..###.##.###.####.#..########.##.....#...

output:

40571

result:

ok single line: '40571'

Test #11:

score: 0
Accepted
time: 57ms
memory: 78512kb

input:

2900 3000 10
2447 135
2447 136
2447 137
2447 138
2447 139
2447 140
2448 140
2448 139
2449 139
2449 138
.#.##.##..#.###########.#####.###....#####.########..##..#.####.##.##.####.####..#.#####.##.#.#.###.##.#.##.####..##.#.####..###..###...##...##.#####.#####.#...#####.####..##.##.#.#..#..####.##..##...

output:

2705

result:

ok single line: '2705'

Test #12:

score: -100
Wrong Answer
time: 195ms
memory: 147256kb

input:

3000 3000 100
2573 1917
2572 1917
2572 1916
2573 1916
2574 1916
2574 1915
2573 1915
2572 1915
2571 1915
2571 1914
2570 1914
2570 1915
2569 1915
2569 1916
2568 1916
2568 1917
2569 1917
2570 1917
2570 1916
2571 1916
2571 1917
2571 1918
2570 1918
2569 1918
2569 1919
2570 1919
2571 1919
2571 1920
2572 1...

output:

9736363732420

result:

wrong answer 1st lines differ - expected: '41693682087973', found: '9736363732420'