QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#563123#3251. 数正方体ElegiaAC ✓1ms4260kbC++232.1kb2024-09-14 02:56:352024-09-14 02:56:39

Judging History

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

  • [2024-09-14 02:56:39]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:4260kb
  • [2024-09-14 02:56:35]
  • 提交

answer

/*
 不, 我想亲眼看看自己选择的终点是什么样的地方.
 */
#include <cmath>
#include <cstring>

#include <algorithm>
#include <limits>
#include <functional>
#include <random>
#include <chrono>
#include <stack>
#include <bitset>
#include <numeric>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <unordered_map>

using ull = unsigned long long;
using ll = long long;

using namespace std;

mt19937 rng(chrono::steady_clock().now().time_since_epoch().count());

const int P = 998244353;

int norm(int x) { return x >= P ? x - P : x; }
int reduce(int x) { return x < 0 ? x + P : x; }
int neg(int x) { return x ? P - x : 0; }
void add(int& x, int y) { if ((x += y - P) < 0) x += P; }
void sub(int& x, int y) { if ((x -= y) < 0) x += P; }
void fam(int& x, int y, int z) { x = (x + y * (ull)z) % P; }
int mpow(int x, unsigned k) {
	if (k == 0) return 1;
	int ret = mpow(x * (ull)x % P, k >> 1);
	if (k & 1) ret = ret * (ull)x % P;
	return ret;
}

char s[1005][1005];

int a[105];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);

	int N, M; cin >> N >> M; cin.ignore();
	for (int i = 0; i != N; ++i) {
		string tmp; getline(cin, tmp);
		copy(tmp.begin(), tmp.end(), s[i]);
		// cerr << s[i] << '\n';
	}
	int ans = 0;
	
	int sx = -1, sy = -1;
	for (int i = 0; i != N; ++i) {
		for (int j = 0; j != M; ++j) {
			if (s[i][j] == '+') {
				sx = i; sy = j; break;
			}
		}
		if (sx != -1) break;
	}
	auto chase = [&](int x, int y) {
		int cnt = 0;
		while (true) {
			// cerr << x << ' ' << y << ' ' << s[x][y] << '\n';
			if (s[x][y + 1] == '-') {
				a[++cnt] = 0;
				y += 4; continue;
			}
			if (s[x + 1][y] == '|') {
				++a[cnt];
				x += 3; continue;
			}
			a[++cnt] = 0; break;
		}
		a[cnt] = 0;
		for (int i = cnt - 1; i; --i) {
			a[i] += a[i + 1];
			ans += a[i];
		}
	};
	while (true) {
		if (sy && s[sx + 1][sy - 1] == '/') {
			sx += 2; sy -= 2;
		} else if (s[sx + 1][sy] == '|') {
			sx += 3; continue;
		} else break;
		chase(sx, sy);
	}
	cout << ans << '\n';

	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3996kb

input:

371 259
......................................................................+---+---+....................................................................................................................................................................................
...................................

output:

84826

result:

ok single line: '84826'

Test #2:

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

input:

398 301
....................................................................................................+---+..............................................................................................................................................................................................

output:

128658

result:

ok single line: '128658'

Test #3:

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

input:

401 301
....................................................................................................+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---...

output:

250000

result:

ok single line: '250000'

Test #4:

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

input:

401 301
....................................................................................................+---+---+---+---+---+---+---+---+---+---+---+......................................................................................................................................................

output:

144484

result:

ok single line: '144484'

Test #5:

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

input:

395 235
..............................................................................................+---+---+....................................................................................................................................
...........................................................

output:

82548

result:

ok single line: '82548'

Test #6:

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

input:

401 301
....................................................................................................+---+---+---+......................................................................................................................................................................................

output:

125068

result:

ok single line: '125068'

Test #7:

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

input:

367 259
..................................................................+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+................................................................................................................................
...................................

output:

80503

result:

ok single line: '80503'

Test #8:

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

input:

397 229
................................................................................................+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+....................................................................
.................................................................

output:

82439

result:

ok single line: '82439'

Test #9:

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

input:

401 301
....................................................................................................+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+......................................................................................................................

output:

127263

result:

ok single line: '127263'

Test #10:

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

input:

398 301
....................................................................................................+---+..............................................................................................................................................................................................

output:

151454

result:

ok single line: '151454'

Test #11:

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

input:

398 301
....................................................................................................+---+---+---+---+---+---+---+---+---+---+..........................................................................................................................................................

output:

182883

result:

ok single line: '182883'

Test #12:

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

input:

401 301
....................................................................................................+---+---+---+---+---+---+---+---+---+---+---+......................................................................................................................................................

output:

209274

result:

ok single line: '209274'