QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#60967#3514. Boulderingabdelrahman001#WA 2ms3596kbC++201.4kb2022-11-08 22:51:592022-11-08 22:52:00

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-08 22:52:00]
  • Judged
  • Verdict: WA
  • Time: 2ms
  • Memory: 3596kb
  • [2022-11-08 22:51:59]
  • 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;
int n, m, r, s, mn = 1e9;
char a[N][N];
int sqr(int x) {
	return x * x;
}
map<array<int, 3>, ld> memo;
ld solve(int i, int j, int cur) {
	if(i == mn)
		return 0;
	if(memo.count({i, j, cur}))
		return memo[{i, j, cur}];
	ld &ans = memo[{i, j, cur}];
	ans = 1e15;
	for(int x = i;x >= mn;x--) {
		for(int y = 0;y < m;y++) {
			if(a[x][y] == '.')
				continue;
			int ndis = sqr(i - x) + sqr(j - y);
			if(ndis > sqr(r))
				continue;
			int c = a[i][j] - '0';
			if(c + cur > s)
				continue;
			ans = min(ans, solve(x, y, c + cur) + sqrt(ndis));
		}
	}
	return ans;
}
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 = n - 1;i >= 0;i--) {
		for(int j = 0;j < m;j++) {
			if(a[i][j] != '.') {
				ld ans = solve(i, j, a[i][j] - '0');
				if(ans == 1e15)
					cout << "impossible";
				else
					cout << fixed << setprecision(9) << ans << endl;
				return 0;
			}
		}
	}
    return 0;
}


详细

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 3596kb

input:

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

output:

12.714776642

result:

wrong answer