QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#562075 | #7733. Cool, It’s Yesterday Four Times More | chiliplus# | WA | 1ms | 3852kb | C++14 | 1.5kb | 2024-09-13 14:51:03 | 2024-09-13 14:51:04 |
Judging History
answer
#include <iostream>
#include <cstdio>
#include <bitset>
#include <queue>
const int N = 1e3 + 10;
const int dx[] = {1, 0, 0, -1}, dy[] = {0, 1, -1, 0};
int m, n;
std::bitset<N> d[N];
char s[N][N];
int getid(int x, int y) { return (x - 1) * m + y; }
void solve(int st)
{
std::queue<int> q;
q.push(st);
d[st][st] = true;
while (!q.empty())
{
int id = q.front(), x = (id - 1) / m + 1, y = (id - 1) % m + 1;
q.pop();
for (int dir = 0; dir < 4; ++ dir) {
int nx = x + dx[dir], ny = y + dy[dir], nid = getid(nx, ny);
if (nx <= 0 || nx > n || ny <= 0 || ny > m || d[st][nid] || s[nx][ny] == 79)
continue;
d[st][nid] = true, q.push(nid);
}
}
}
void work()
{
std::cin >> n >> m;
for (int i = 1; i <= n; ++ i) d[i].reset();
for (int i = 1; i <= n; ++ i) scanf("%s", s[i] + 1);
for (int i = 1; i <= n; ++ i)
for (int j = 1; j <= m; ++ j)
if (s[i][j] != 79) solve(getid(i, j));
int res = 0;
for (int i = 1; i <= n * m; ++ i) {
if (s[(i - 1) / m + 1][(i - 1) % m + 1] == 79) continue;
bool flag = true;
for (int j = 1; j <= n * m; ++ j) {
if (i == j || s[(j - 1) / m + 1][(j - 1) % m + 1] == 79) continue;
if ((d[i] & (j > i ? d[j] >> (j - i) : d[j] << (i - j))) == d[i]) {
flag = false;
break;
}
}
// if (flag) std::cout << (i - 1) / m + 1 << ' ' << (i - 1) % m + 1 << '\n';
res += flag;
}
printf("%d\n", res);
}
int main()
{
int T;
std::cin >> T;
while (T --) work();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3852kb
input:
4 2 5 .OO.. O..O. 1 3 O.O 1 3 .O. 2 3 OOO OOO
output:
3 1 0 0
result:
ok 4 lines
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3800kb
input:
200 2 4 OOO. OO.. 2 3 OOO .O. 3 3 O.O OOO OO. 4 1 . . O O 1 2 .O 1 1 . 2 5 .OO.. .O.O. 2 1 O O 1 1 O 1 3 .OO 5 1 O O . O . 5 2 O. .. O. .O .. 5 3 ... ... .OO ..O OOO 3 5 ..O.O .O.O. .OO.O 5 2 .O OO O. O. .. 2 1 O O 3 5 .O.OO O...O ..OO. 1 5 ..... 5 1 O . O . . 5 3 OOO OO. .OO OO. O.O 2 1 O . 5 2 O. ...
output:
3 1 0 2 1 1 4 0 0 1 0 7 8 6 3 0 6 5 2 3 1 5 4 5 2 1 0 4 1 1 1 2 1 0 5 5 2 1 4 3 0 2 2 2 1 0 3 2 5 3 3 3 2 3 2 1 0 3 3 1 1 2 2 1 4 5 4 4 2 1 2 2 2 1 1 1 3 0 1 1 2 1 4 1 4 1 3 1 2 5 4 3 2 1 0 1 6 2 4 9 0 3 2 1 1 1 4 3 1 3 1 7 2 0 1 1 2 2 1 3 3 4 0 1 6 2 2 1 2 2 2 5 1 1 2 3 0 5 1 10 1 3 2 4 0 5 1 3 1 1...
result:
wrong answer 2nd lines differ - expected: '0', found: '1'