QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#518876 | #7034. Honeycomb | wnsyou | WA | 213ms | 121840kb | C++23 | 1.9kb | 2024-08-14 13:38:09 | 2024-08-14 13:38:11 |
Judging History
answer
#include <bits/stdc++.h>
#define _1 (__int128)1
using namespace std;
using ll = long long;
using pii = pair<int, int>;
void FileIO (const string s) {
freopen(string(s + ".in").c_str(), "r", stdin);
freopen(string(s + ".out").c_str(), "w", stdout);
}
const int N = 4010, M = 6010, C = 1e6 + 10;
int T, n, m, id[N][M], cnt, st, en, dis[C];
string s;
char c[N][M];
vector<int> g[C];
queue<int> q;
void Record (int x, int lv) {
if (dis[x]) return ;
dis[x] = lv, q.push(x);
}
void Solve () {
cin >> n >> m, cin.get(), cnt = 0;
for (int i = 1; i <= 4 * n + 3; i++) {
getline(cin, s);
for (int j = 1; j <= 6 * m + 3; j++)
c[i][j] = (j <= s.size() ? s[j - 1] : ' ');
//for (int j = 1; j <= 6 * m + 3; j++)
// cout << c[i][j];
//cout << '\n';
}
for (int i = 3; i <= 4 * n + 1; i += 2)
for (int j = (i / 2 % 2 ? 5 : 11); j <= 6 * m + 3; j += 12) {
id[i][j] = ++cnt;
if (c[i][j] == 'S') st = cnt;
else if (c[i][j] == 'T') en = cnt;
}
for (int i = 3; i <= 4 * n + 1; i += 2)
for (int j = (i / 2 % 2 ? 5 : 11); j <= 6 * m + 3; j += 12) {
if (c[i - 2][j] == ' ') g[id[i][j]].push_back(id[i - 4][j]), g[id[i - 4][j]].push_back(id[i][j]);
if (c[i - 1][j - 3] == ' ') g[id[i][j]].push_back(id[i - 2][j - 6]), g[id[i - 2][j - 6]].push_back(id[i][j]);
if (c[i + 1][j - 3] == ' ') g[id[i][j]].push_back(id[i + 2][j - 6]), g[id[i + 2][j - 6]].push_back(id[i][j]);
}
Record(st, 1);
//cout << st << ' ' << en << '\n';
while (q.size()) {
int x = q.front();
q.pop();
//cout << x << ' ' << dis[x] << '\n';
for (int i : g[x])
Record(i, dis[x] + 1);
}
cout << dis[en];
for (int i = 1; i <= cnt; i++)
g[i] = vector<int> (), dis[i] = 0;
}
signed main () {
ios::sync_with_stdio(0), cin.tie(0);
// FileIO("");
for (cin >> T; T--; Solve(), cout << '\n') {}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 3ms
memory: 7724kb
input:
1 3 4 +---+ +---+ / \ / \ + +---+ +---+ \ \ / \ + + S +---+ T + / \ / / + +---+ + + \ \ / \ +---+ +---+ + / / + +---+ + + \ ...
output:
7
result:
ok single line: '7'
Test #2:
score: -100
Wrong Answer
time: 213ms
memory: 121840kb
input:
400 67 89 +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ ...
output:
91 132 8 71 57 51 83 151 400 67 9 3 196 597 33 212 49 29 527 20 23 51 280 22 40 91 541 33 488 125 13 357 263 220 47 182 293 254 11 82 97 39 176 15 65 13 65 75 32 9 60 77 152 14 69 110 45 555 191 173 109 207 7 225 232 97 108 326 118 79 78 414 222 44 31 58 47 228 32 48 15 133 521 350 242 85 201 48 105...
result:
wrong answer 379th lines differ - expected: '-1', found: '0'