QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#61006#3514. Boulderingabdelrahman001WA 23ms113384kbC++202.0kb2022-11-09 04:22:242022-11-09 04:22:27

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-11-09 04:22:27]
  • Judged
  • Verdict: WA
  • Time: 23ms
  • Memory: 113384kb
  • [2022-11-09 04:22:24]
  • Submitted

answer

#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
const int N = 50 + 5;
const int M = 6e3 + 5;
int n, m, r, s, mn = 1e9;
ld d[N][N][M];
char a[N][N];
vector<array<int, 3>> g[N][N];
int sqr(int x) {
	return x * x;
}
ld dij(int i, int j) {
	priority_queue<pair<ld, array<int, 3>>> q;
	for(int i = 0;i < n;i++) {
		for(int j = 0;j < m;j++) {
			for(int k = 0;k < M;k++)
				d[i][j][k] = 1e9;
		}
	}
	//int c = a[i][j] - '0';
	int c = 0;
	d[i][j][c] = 0;
	q.push({0, {c, i, j}});
	while(!q.empty()) {
		ld dis = -q.top().first;
		int curi = q.top().second[1];
		int curj = q.top().second[2];
		int curs = q.top().second[0];
		q.pop();
		if(d[curi][curj][curs] < dis)
			continue;
		if(curi == mn)
			return dis;
		for(auto k : g[curi][curj]) {
			int ni = k[0];
			int nj = k[1];
			ld ndis = dis + sqrt(k[2]);
			int c = a[ni][nj] - '0';
			if(c + curs > s)
				continue;
			int cs = c + curs;
			if(ndis < d[ni][nj][cs]) {
				d[ni][nj][cs] = ndis;
				q.push({-ndis, {cs, ni, nj}});
			}
		}
	}
	return 1e15;
}
int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> m >> r >> s;
    for(int i = 0;i < n;i++) {
		for(int j = 0;j < m;j++) {
			cin >> a[i][j];
			if(a[i][j] != '.')
				mn = min(mn, i);
		}
	}
	for(int i = 1;i < n;i++) {
		for(int j = 0;j < m;j++) {
			for(int x = i;x >= 0;x--) {
				for(int y = 0;y < m;y++) {
					if(a[i][j] == '.' || a[x][y] == '.')
						continue;
					int dis = sqr(i - x) + sqr(j - y);
					if(dis > sqr(r))
						continue;
					g[i][j].push_back({x, y, dis});
				}
			}
		}
	}
	for(int i = n - 1;i >= 0;i--) {
		for(int j = 0;j < m;j++) {
			if(a[i][j] != '.') {
				ld ans = dij(i, j);
				if(ans == 1e15)
					cout << "impossible";
				else
					cout << fixed << setprecision(9) << ans << endl;
				return 0;
			}
		}
	}
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 4ms
memory: 39068kb

input:

12 11 3 11
...........
........3..
.......3.1.
...........
.......2...
.....2.....
.1.1.......
.....2.....
.1.........
...2.......
.1.........
...........

output:

13.543203767

result:

ok 

Test #2:

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

input:

8 16 3 15
......1.........
....1..1.1......
..2........1....
...2......1.....
.....4.1..2..1..
................
.......1........
................

output:

6.414213562

result:

ok 

Test #3:

score: 0
Accepted
time: 7ms
memory: 32964kb

input:

10 10 2 10
...2......
..........
...5.2....
..........
.....3....
....5.....
..2....2..
..1.......
....2.....
..1.......

output:

impossible

result:

ok 

Test #4:

score: 0
Accepted
time: 5ms
memory: 14312kb

input:

5 5 1 100
....1
.1111
.1.9.
.119.
..1..

output:

6.000000000

result:

ok 

Test #5:

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

input:

6 7 3 10
..6....
..1....
.......
.5..1..
.......
..1....

output:

6.656854249

result:

ok 

Test #6:

score: 0
Accepted
time: 4ms
memory: 9316kb

input:

2 18 2 5
.............1....
...............9..

output:

impossible

result:

ok 

Test #7:

score: -100
Wrong Answer
time: 23ms
memory: 113384kb

input:

25 25 1 1000000
9........................
21.21921.21921.21921.2193
92.92.92.92.92.92.92.92.3
.2..2..2..2..2..2..2..2.3
12.12.12.12.12.12.12.12.3
29.29.29.29.29.29.29.29.3
2..2..2..2..2..2..2..2..3
21.21.21.21.21.21.21.21.3
92.92.92.92.92.92.92.92.3
.2..2..2..2..2..2..2..2.3
12.12.12.12.12.12.12.12....

output:

impossible

result:

wrong answer