QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#282324 | #3251. 数正方体 | kilo_tobo_tarjen# | AC ✓ | 10ms | 11192kb | C++20 | 1.3kb | 2023-12-11 19:12:38 | 2023-12-11 19:12:38 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const char el = '\n';
typedef long long ll;
char get(vector<string> &s, int i, int j) {
if (i >= s.size() || i < 0) return ' ';
if (j >= s[0].size() || j < 0) return ' ';
return s[i][j];
}
int dfs(vector<string> &s, int i, int j, vector<pair<int, int>> &res) {
if (get(s, i, j) != '+') return 0;
s[i][j] = '#';
res.push_back({i, j});
int ans = 0, tmp = 1;
for (auto x : {i, i - 3})
for (auto y : {j, j + 4}) {
ans += dfs(s, x, y, res);
auto ch = get(s, x, y);
if (ch != '+' && ch != '#') tmp = 0;
}
return ans + tmp;
}
int solve(vector<string> s) {
bool flg = false;
for (auto &v : s)
for (auto ch : v) flg = flg || ch == '/';
if (!flg) return 0;
vector<pair<int, int>> a;
int res = dfs(s, s.size() - 1, 0, a);
for (auto &[x, y] : a)
s[x][y] = ' ', s[x - 2][y + 2] = '+', s[x - 1][y + 1] = ' ';
for (auto &v : s) v.erase(v.begin(), v.begin() + 2);
s.erase(s.end() - 2, s.end());
return res + solve(s);
}
int main() {
cout << setprecision(15);
int n, m;
cin >> n >> m;
vector<string> a(n);
for (auto &v : a) {
getchar();
v.resize(m);
for (auto &ch : v) ch = getchar();
}
cout << solve(a) << el;
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 5ms
memory: 7712kb
input:
371 259 ......................................................................+---+---+.................................................................................................................................................................................... ...................................
output:
84826
result:
ok single line: '84826'
Test #2:
score: 0
Accepted
time: 8ms
memory: 10204kb
input:
398 301 ....................................................................................................+---+..............................................................................................................................................................................................
output:
128658
result:
ok single line: '128658'
Test #3:
score: 0
Accepted
time: 10ms
memory: 11192kb
input:
401 301 ....................................................................................................+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---...
output:
250000
result:
ok single line: '250000'
Test #4:
score: 0
Accepted
time: 7ms
memory: 10384kb
input:
401 301 ....................................................................................................+---+---+---+---+---+---+---+---+---+---+---+......................................................................................................................................................
output:
144484
result:
ok single line: '144484'
Test #5:
score: 0
Accepted
time: 0ms
memory: 8316kb
input:
395 235 ..............................................................................................+---+---+.................................................................................................................................... ...........................................................
output:
82548
result:
ok single line: '82548'
Test #6:
score: 0
Accepted
time: 7ms
memory: 10268kb
input:
401 301 ....................................................................................................+---+---+---+......................................................................................................................................................................................
output:
125068
result:
ok single line: '125068'
Test #7:
score: 0
Accepted
time: 4ms
memory: 7756kb
input:
367 259 ..................................................................+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+................................................................................................................................ ...................................
output:
80503
result:
ok single line: '80503'
Test #8:
score: 0
Accepted
time: 5ms
memory: 8420kb
input:
397 229 ................................................................................................+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+.................................................................... .................................................................
output:
82439
result:
ok single line: '82439'
Test #9:
score: 0
Accepted
time: 3ms
memory: 10368kb
input:
401 301 ....................................................................................................+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+......................................................................................................................
output:
127263
result:
ok single line: '127263'
Test #10:
score: 0
Accepted
time: 0ms
memory: 10300kb
input:
398 301 ....................................................................................................+---+..............................................................................................................................................................................................
output:
151454
result:
ok single line: '151454'
Test #11:
score: 0
Accepted
time: 4ms
memory: 10628kb
input:
398 301 ....................................................................................................+---+---+---+---+---+---+---+---+---+---+..........................................................................................................................................................
output:
182883
result:
ok single line: '182883'
Test #12:
score: 0
Accepted
time: 9ms
memory: 10832kb
input:
401 301 ....................................................................................................+---+---+---+---+---+---+---+---+---+---+---+......................................................................................................................................................
output:
209274
result:
ok single line: '209274'