QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#790302 | #3251. 数正方体 | baoyangawa | WA | 3ms | 30584kb | C++14 | 3.4kb | 2024-11-28 10:10:18 | 2024-11-28 10:10:19 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
#define frr(a) freopen(a, "r", stdin)
#define fww(a) freopen(a, "w", stdout)
#define MP make_pair
#define eb emplace_back
using namespace std;
using ll = long long;
const int inf = 0x3f3f3f3f, MB = 1 << 20;
const ll INF = 0x3f3f3f3f3f3f3f3f;
struct fio {
char ib[MB + 100], *p, *q;
fio() {p = q = ib;}
char gc() {
return getchar();
if (p == q) {
q = (p = ib) + fread(ib, 1, MB, stdin);
if (p == q) return EOF;
} return *p++;
}
template <typename T> void read(T& x) {
char c = gc(), l = 0; x = 0;
while (!isdigit(c)) l = c, c = gc();
while ( isdigit(c)) x = (x << 1) + (x << 3) + c - 48, c = gc();
if (l == '-') x = -x;
}
bool bk(char c) {
return c == '\r' || c == '\n' || c == '\t' || c == EOF;
}
void read(char& x) {
char c = gc();
while (bk(c)) c = gc();
x = c;
}
void read(string& x) {
char c = gc(); x.clear();
while ( bk(c)) c = gc();
while (!bk(c)) x += c, c = gc();
}
template <typename T, typename ...Argc> void read(T& x, Argc&... argc) {
read(x), read(argc...);
}
} IO;
const int N = 7110;
string s[N];
int R, C, n, m;
ll d[N][N];
bool is[N][N];
signed main() {
// fww("out");
IO.read(R, C);
int s1 = 0;
for (int i = 1; i <= R; i++) {
// IO.read(s[i]);
getline(cin, s[i]);
s[i] = "@" + s[i];
for (int o = 1; o <= 10; o++) s[i] += '@';
}
// for (int i = 1; i <= R; i++) {
// cout << s[i] << '\n';
// }
for (int i = 1; i <= C; i++) s1 += s[R][i] == '.';
n = s1 / 2, m = (C - 1 - s1) / 4;
// printf("n:%d m:%d\n", n, m);
vector <int> v; ll mx = 0;
for (int i = 0; i <= C + 10; i++) {
s[0].push_back('@');
}
for (int i = 1; i <= 10; i++) {
s[R + i] = s[0];
}
for (int i = 1; i <= R; i++) {
for (int j = 1; j <= C; j++) {
if (s[i][j] != '+') continue;
is[i][j] = 1;
if (
i <= R - 2 && j <= C - 3 &&
s[i + 1][j - 1] == '/' && s[i + 1][j + 3] == '/' &&
s[i][j + 1] == '-' && s[i][j + 2] == '-' && s[i][j + 3] == '-' && s[i][j + 4] == '+' &&
s[i + 1][j] == ' ' && s[i + 1][j + 1] == ' ' && s[i + 1][j + 2] == ' '
) v.eb(d[i][j]);
if (i < R && s[i + 1][j] == '|') {
if (is[i + 3][j]) {
assert(d[i + 3][j] == d[i][j] + 1);
}
d[i + 3][j] = d[i][j] + 1;
is[i + 3][j] = 1;
}
if (j < C && s[i][j + 1] == '-') {
if (is[i][j + 4]) {
assert(d[i][j + 4] == d[i][j]);
}
d[i][j + 4] = d[i][j];
is[i][j + 4] = 1;
}
if (i < R && j > 1 && s[i + 1][j - 1] == '/') {
if (is[i + 2][j - 2]) {
assert(d[i + 2][j - 2] == d[i][j]);
}
d[i + 2][j - 2] = d[i][j];
is[i + 2][j - 2] = 1;
}
}
}
for (ll x : v) mx = max(mx, x);
ll res = 0;
for (int x : v) {
assert(mx - x + 1 >= 1);
res += mx - x + 1;
}
assert((ll)v.size() == n * m);
// for (int i = 1; i <= R; i++) {
// for (int j = 1; j <= C; j++) {
// if (s[i][j] == '+') cout << d[i][j];
// else cout << ' ';
// } puts("");
// }
printf("%lld\n", res);
return 0;
}
/*
14 17
....+---+---+....
.../ / /|....
..+---+---+ |....
./ /| | +---+
+---+ | |/ /|
| | +---+---+ |
| |/ /| | +
+---+---+ | |/|
| | | +---+ |
| | |/ /| +
+---+---+---+ |/.
| | | | +..
| | | |/...
+---+---+---+....
8 9
....+---+
.../ /|
..+---+ |
./ /| +
+---+ |/.
| | +..
| |/...
+---+....
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 3ms
memory: 28172kb
input:
371 259 ......................................................................+---+---+.................................................................................................................................................................................... ...................................
output:
84826
result:
ok single line: '84826'
Test #2:
score: 0
Accepted
time: 0ms
memory: 28536kb
input:
398 301 ....................................................................................................+---+..............................................................................................................................................................................................
output:
128658
result:
ok single line: '128658'
Test #3:
score: -100
Wrong Answer
time: 3ms
memory: 30584kb
input:
401 301 ....................................................................................................+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---...
output:
2500
result:
wrong answer 1st lines differ - expected: '250000', found: '2500'