QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#790224#2925. Parking LotAutiFancersAC ✓570ms3996kbC++14996b2024-11-28 08:40:522024-11-28 08:40:53

Judging History

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

  • [2024-11-28 08:40:53]
  • 评测
  • 测评结果:AC
  • 用时:570ms
  • 内存:3996kb
  • [2024-11-28 08:40:52]
  • 提交

answer

#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<iomanip>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
using namespace std;

const int N=55,inf=1e9;
int n,m;
int a[N][N]; 
double dp[N][N];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	cin>>n>>m;
	rep(i,0,n-1) rep(j,0,m-1) {
		char x;cin>>x;
		if(x=='#') a[i][j]=1;
	}
	
	rep(i,0,n) rep(j,0,m) dp[i][j]=inf;
	dp[0][0]=0;
	
	rep(i,0,n) rep(j,0,m) {
		if(i>0) dp[i][j]=min(dp[i][j],dp[i-1][j]+1);
		if(j>0) dp[i][j]=min(dp[i][j],dp[i][j-1]+1);
		rep(x,0,i-1) rep(y,0,j-1) {
			bool ok=1;
			rep(l,x,i-1) rep(r,y,j-1) {
				if((r-y)*(i-x)<(l-x+1)*(j-y) && (l-x)*(j-y)<(r-y+1)*(i-x) && a[l][r]) {
					ok=0;
					break;
				}
				if(!ok) break;
			}
			if(ok) dp[i][j]=min(dp[i][j],dp[x][y]+sqrt((i-x)*(i-x)+(j-y)*(j-y)));
		}
	}
	
	cout<<fixed<<setprecision(8)<<dp[n][m]<<'\n';

	return 0;
}
/*
4 4
..#.
.#.#
###.
.#..
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1 1
.

output:

1.41421356

result:

ok found '1.4142136', expected '1.4142136', error '0.0000000'

Test #2:

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

input:

1 1
#

output:

2.00000000

result:

ok found '2.0000000', expected '2.0000000', error '0.0000000'

Test #3:

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

input:

1 3
.#.

output:

3.41421356

result:

ok found '3.4142136', expected '3.4142136', error '0.0000000'

Test #4:

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

input:

1 3
##.

output:

3.41421356

result:

ok found '3.4142136', expected '3.4142136', error '0.0000000'

Test #5:

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

input:

2 3
.#.
.#.

output:

3.82842712

result:

ok found '3.8284271', expected '3.8284271', error '0.0000000'

Test #6:

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

input:

2 6
#..#.#
#.#..#

output:

6.47213595

result:

ok found '6.4721360', expected '6.4721360', error '0.0000000'

Test #7:

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

input:

6 5
.####
#...#
#.##.
#.###
##...
####.

output:

8.22677276

result:

ok found '8.2267728', expected '8.2267728', error '0.0000000'

Test #8:

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

input:

12 10
##########
##########
###....###
##########
#..####..#
###....###
#######.##
...#######
###....###
#######..#
###....###
##########

output:

18.94427191

result:

ok found '18.9442719', expected '18.9442719', error '0.0000000'

Test #9:

score: 0
Accepted
time: 570ms
memory: 3860kb

input:

50 50
..................................................
..................................................
..................................................
..................................................
..................................................
..........................................

output:

70.71067812

result:

ok found '70.7106781', expected '70.7106781', error '0.0000000'

Test #10:

score: 0
Accepted
time: 10ms
memory: 3852kb

input:

13 47
...............................................
...............................................
...............................................
...............................................
...............................................
...............................................
.........

output:

48.76474136

result:

ok found '48.7647414', expected '48.7647414', error '0.0000000'

Test #11:

score: 0
Accepted
time: 31ms
memory: 3824kb

input:

50 50
##################################################
##################################################
##################################################
##################################################
##################################################
#######################################...

output:

100.00000000

result:

ok found '100.0000000', expected '100.0000000', error '0.0000000'

Test #12:

score: 0
Accepted
time: 2ms
memory: 3936kb

input:

47 13
#############
#############
#############
#############
#############
#############
#############
#############
#############
#############
#############
#############
#############
#############
#############
#############
#############
#############
#############
#############
#############
...

output:

60.00000000

result:

ok found '60.0000000', expected '60.0000000', error '0.0000000'

Test #13:

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

input:

49 1
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

output:

49.01020302

result:

ok found '49.0102030', expected '49.0102030', error '0.0000000'

Test #14:

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

input:

49 1
.
.
#
#
#
.
.
.
.
.
#
#
#
#
#
#
#
#
#
#
.
.
.
.
#
.
.
.
.
#
#
#
.
#
#
.
.
#
#
#
#
#
.
#
#
.
.
.
.

output:

49.09901951

result:

ok found '49.0990195', expected '49.0990195', error '0.0000000'

Test #15:

score: 0
Accepted
time: 1ms
memory: 3956kb

input:

3 45
.............................................
.............................................
.............................................

output:

45.09988914

result:

ok found '45.0998891', expected '45.0998891', error '0.0000000'

Test #16:

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

input:

3 45
###..####.##.#.#.##..#.#############...##.###
##.###..#.##.#.##.#.#...#.......#...##..###.#
###...##..##........#..###.#...#..#.#.....#..

output:

45.40615530

result:

ok found '45.4061553', expected '45.4061553', error '0.0000000'

Test #17:

score: 0
Accepted
time: 477ms
memory: 3676kb

input:

50 50
..................................................
........#.........................................
..................................................
..................................................
..................................................
..........................................

output:

70.71067812

result:

ok found '70.7106781', expected '70.7106781', error '0.0000000'

Test #18:

score: 0
Accepted
time: 9ms
memory: 3908kb

input:

13 47
......................................#........
...............................................
...........#.....#.............................
...............................................
...............................................
...............................................
.........

output:

48.76474136

result:

ok found '48.7647414', expected '48.7647414', error '0.0000000'

Test #19:

score: 0
Accepted
time: 201ms
memory: 3944kb

input:

40 46
..............................................
......................#................#......
...........................#..................
............#.................................
..............................................
..............................................
...............

output:

60.95900262

result:

ok found '60.9590026', expected '60.9590026', error '0.0000000'

Test #20:

score: 0
Accepted
time: 248ms
memory: 3928kb

input:

50 50
........................#.........................
.......#.......#....#.........#.............#.....
...............#..................................
.........#...........#................#..#........
....#........#............................#....##.
....#.....#....................#.#........

output:

70.98117195

result:

ok found '70.9811720', expected '70.9811719', error '0.0000000'

Test #21:

score: 0
Accepted
time: 9ms
memory: 3984kb

input:

47 13
..........#..
.............
.............
..........#..
....#....#...
...##........
...#......#..
.............
.............
.............
.............
.............
...........#.
.............
........#....
.............
.............
........#....
........#..#.
.............
.............
...

output:

48.77248130

result:

ok found '48.7724813', expected '48.7724813', error '0.0000000'

Test #22:

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

input:

40 46
.......#...........#.#.......#................
.#..............................#........#....
...........................#..............#...
..............#...............................
.....................................#.......#
.#..........................#...........#.....
.......#.......

output:

61.13120871

result:

ok found '61.1312087', expected '61.1312087', error '0.0000000'

Test #23:

score: 0
Accepted
time: 68ms
memory: 3944kb

input:

50 50
.#...###.#..#.#.....#.#..###..#.#..#.....###.##.#.
####..###..#...##..######.##..#####..##.###..##.##
#####..#..###..##..#.#..#.##...#.#####.##..#####.#
....##....#.#####.#.##.##....#.###.#...#.#.##.##.#
##.....#.##.########..##..#....#.##..#.##.##...#..
###.#..##.##.#####.##..##.#.#.#.#.#..##...

output:

74.46412964

result:

ok found '74.4641296', expected '74.4641296', error '0.0000000'

Test #24:

score: 0
Accepted
time: 44ms
memory: 3976kb

input:

47 43
#.#...#.#...##.#.##.##.#.#....#.####.#..#..
.####....#..#..#..#.#...####...#.#.......##
.#.#####.#..#..#..#####.#####.#.#.###..##.#
.###.#####.#....######...#.#.#.#..##.###...
.#.###.......#..#####..#######..#..#....#.#
#..####..#.##.#..#..##.#.#.###.####.###.#..
.#.##.#####.#.##.##..##.#.##.....

output:

67.73007856

result:

ok found '67.7300786', expected '67.7300786', error '0.0000000'

Test #25:

score: 0
Accepted
time: 45ms
memory: 3872kb

input:

44 48
##....###...#.#..##....###..##.##.....###.###...
#..##..#..#........###.###....##.##..##...#.###.
.#....###...#.......#.###..##..##...#.####.#....
.#.#.###...#.#..#..###..##....###..####....#.#..
...#.#.#...##..#..###.###.#.#..#...#.###..##.#..
##.#.###...####.#..#..#####.##..#.##.##.........
...

output:

69.05970169

result:

ok found '69.0597017', expected '69.0597017', error '0.0000000'

Test #26:

score: 0
Accepted
time: 51ms
memory: 3940kb

input:

50 50
..#.####..#.##########..#######.####.#.#.#########
....#####.##..#########.#######.##.##..##.####..#.
##.#####.##.#.###.##..#.#.#####..#######.###.#####
.##..######..#.########.#..######..######.######.#
##.#################.#####.##..##.########.#######
###.#.#..##.#########.#.###.####.##.###...

output:

81.58702863

result:

ok found '81.5870286', expected '81.5870286', error '0.0000000'

Test #27:

score: 0
Accepted
time: 52ms
memory: 3864kb

input:

50 50
#####.#######.##..#...########..#####.###..###.#.#
###.#####.#.##....#....#.###.#####.###.###.##.##.#
..#.######..#..##..#..######.####.#.#########..##.
#####..####.###.##.########.#.###########.###.###.
###.#######.###....##########..###.##.#.###.#..###
.##..##.##.###.##.#########.#.###.#####...

output:

80.71013426

result:

ok found '80.7101343', expected '80.7101343', error '0.0000000'

Test #28:

score: 0
Accepted
time: 51ms
memory: 3932kb

input:

50 50
#..#####..######..##.#####.###########.##.###.###.
#.######.##.###.##.####.###.#####.###.#.##...#####
#########.##..##.####...#.##########.#####.#######
########...#..#..#####.##.#####.##.###.#..#######.
.##############.######..###.#..#####.######.####.#
##.##.#.###.##.#.#####.#..##.###.##.###...

output:

81.33509273

result:

ok found '81.3350927', expected '81.3350927', error '0.0000000'

Test #29:

score: 0
Accepted
time: 50ms
memory: 3804kb

input:

50 50
##.########.#####################.#######..######.
###.#####.##.###.########...####..##########.#..##
##.#.##.##...##.###########.#####.####.##.######.#
#..#####..###.#.##.######.##########.###.###.#####
###.####..########.#.######.###.####.########..###
######.##.#######.#######.#..######...#...

output:

80.72298004

result:

ok found '80.7229800', expected '80.7229800', error '0.0000000'

Test #30:

score: 0
Accepted
time: 44ms
memory: 3804kb

input:

50 50
#########.##########.##.############.#######.#####
#########################.#######.########.#######
..###########.#######.#####.#######..#######.##.##
##########.##################.###################.
############.#########.################..#.#######
#########.##########.######.##.########...

output:

86.73396657

result:

ok found '86.7339666', expected '86.7339666', error '0.0000000'

Test #31:

score: 0
Accepted
time: 45ms
memory: 3992kb

input:

50 50
########..#############.###################..#####
#######.############.############.#####.##########
###########.#########################..#####.##.##
#####.###############.##################.#####.###
################..############..#########.########
#############################.######.##...

output:

86.94117221

result:

ok found '86.9411722', expected '86.9411722', error '0.0000000'

Test #32:

score: 0
Accepted
time: 42ms
memory: 3996kb

input:

50 50
#####..#.##.######.#########..#######.##..########
###################...####################.######.
.####.######.###########.#######################.#
################.##########.##..################.#
######.#.#################.#########.#########.#.#
##########..######.#############.######...

output:

86.40011603

result:

ok found '86.4001160', expected '86.4001160', error '0.0000000'

Test #33:

score: 0
Accepted
time: 37ms
memory: 3976kb

input:

50 50
.###############.#########.##.###.#########.######
#####.###..##############.###########.#.#########.
################.#####.##############.#######.####
#######..###.####################.#.#####.###..###
#####.#.####.#####.####.#.######################.#
#######.################.##.#####.##.##...

output:

86.40011603

result:

ok found '86.4001160', expected '86.4001160', error '0.0000000'

Test #34:

score: 0
Accepted
time: 32ms
memory: 3932kb

input:

50 50
....##############################################
###.....##########################################
#######.....######################################
###########.....##################################
###############....###############################
###################.###################...

output:

74.29118707

result:

ok found '74.2911871', expected '74.2911871', error '0.0000000'

Test #35:

score: 0
Accepted
time: 35ms
memory: 3936kb

input:

50 50
.#################################################
.#################################################
..################################################
#.################################################
#.################################################
#..####################################...

output:

74.86044427

result:

ok found '74.8604443', expected '74.8604443', error '0.0000000'

Test #36:

score: 0
Accepted
time: 36ms
memory: 3928kb

input:

50 50
.#################################################
..################################################
#..###############################################
##..##############################################
###..#############################################
####.##################################...

output:

72.68003643

result:

ok found '72.6800364', expected '72.6800364', error '0.0000000'

Test #37:

score: 0
Accepted
time: 36ms
memory: 3868kb

input:

50 50
.#################################################
..################################################
#.################################################
#..###############################################
##..##############################################
###.###################################...

output:

71.90117373

result:

ok found '71.9011737', expected '71.9011737', error '0.0000000'

Test #38:

score: 0
Accepted
time: 33ms
memory: 3808kb

input:

50 50
.#################################################
.#################################################
.#################################################
.#################################################
.#################################################
.######################################...

output:

80.07384714

result:

ok found '80.0738471', expected '80.0738471', error '0.0000000'

Test #39:

score: 0
Accepted
time: 35ms
memory: 3928kb

input:

50 50
.#################################################
..################################################
#.################################################
#..###############################################
##.###############################################
##..###################################...

output:

76.60299007

result:

ok found '76.6029901', expected '76.6029901', error '0.0000000'

Test #40:

score: 0
Accepted
time: 35ms
memory: 3864kb

input:

50 50
...###############################################
##....############################################
#####...##########################################
########...#######################################
##########....####################################
#############...#######################...

output:

76.78431601

result:

ok found '76.7843160', expected '76.7843160', error '0.0000000'

Test #41:

score: 0
Accepted
time: 35ms
memory: 3992kb

input:

50 50
.#################################################
#.################################################
##.###############################################
###.##############################################
####.#############################################
#####.#################################...

output:

75.99652040

result:

ok found '75.9965204', expected '75.9965204', error '0.0000000'

Test #42:

score: 0
Accepted
time: 30ms
memory: 3940kb

input:

50 50
.#################################################
#.################################################
##.###############################################
###.##############################################
####.#############################################
#####.#################################...

output:

72.57430736

result:

ok found '72.5743074', expected '72.5743074', error '0.0000000'

Test #43:

score: 0
Accepted
time: 30ms
memory: 3976kb

input:

50 50
.#################################################
#.################################################
##.###############################################
###.##############################################
####.#############################################
#####.#################################...

output:

76.40909097

result:

ok found '76.4090910', expected '76.4090910', error '0.0000000'

Test #44:

score: 0
Accepted
time: 34ms
memory: 3868kb

input:

50 50
.#################################################
#.################################################
##.###############################################
###.##############################################
####.#############################################
#####.#################################...

output:

73.43649375

result:

ok found '73.4364937', expected '73.4364937', error '0.0000000'

Test #45:

score: 0
Accepted
time: 31ms
memory: 3872kb

input:

50 50
.#################################################
#.################################################
##.###############################################
###.##############################################
####.#############################################
#####.#################################...

output:

73.76817850

result:

ok found '73.7681785', expected '73.7681785', error '0.0000000'

Test #46:

score: 0
Accepted
time: 39ms
memory: 3832kb

input:

50 50
.#################################################
#.################################################
#..###############################################
##..##############################################
###..#############################################
####..#################################...

output:

70.82914726

result:

ok found '70.8291473', expected '70.8291473', error '0.0000000'

Test #47:

score: 0
Accepted
time: 39ms
memory: 3872kb

input:

50 50
.#################################################
#..###############################################
##..##############################################
###..#############################################
####..############################################
#####..################################...

output:

70.73374850

result:

ok found '70.7337485', expected '70.7337485', error '0.0000000'

Test #48:

score: 0
Accepted
time: 37ms
memory: 3824kb

input:

50 50
.#################################################
#.################################################
#..###############################################
##..##############################################
###..#############################################
####..#################################...

output:

71.44120212

result:

ok found '71.4412021', expected '71.4412021', error '0.0000000'

Test #49:

score: 0
Accepted
time: 32ms
memory: 3824kb

input:

50 50
........................##########################
#######################........................###
###############################################.##
###############################################.##
###############################################.##
#######################################...

output:

95.24923412

result:

ok found '95.2492341', expected '95.2492341', error '0.0000000'

Test #50:

score: 0
Accepted
time: 30ms
memory: 3868kb

input:

50 50
.............#####################################
#############.............########################
##########################.............###########
#######################################.##########
#######################################.##########
#######################################...

output:

87.39954878

result:

ok found '87.3995488', expected '87.3995488', error '0.0000000'

Test #51:

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

input:

4 4
..#.
.#.#
###.
.#..

output:

5.88634952

result:

ok found '5.8863495', expected '5.8863495', error '0.0000000'

Test #52:

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

input:

2 2
##
##

output:

4.00000000

result:

ok found '4.0000000', expected '4.0000000', error '0.0000000'