QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#562069 | #7733. Cool, It’s Yesterday Four Times More | chiliplus# | WA | 1ms | 3872kb | C++14 | 1.4kb | 2024-09-13 14:47:23 | 2024-09-13 14:47:24 |
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, sta[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) 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;
}
}
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: 3784kb
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: 3872kb
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 5 0 0 1 1 4 6 5 4 0 7 4 2 3 1 5 6 5 2 1 0 4 4 2 1 3 1 0 5 4 1 2 5 3 0 4 3 3 3 0 3 4 4 4 5 5 2 4 3 1 3 4 3 4 4 3 3 3 6 6 3 6 2 2 2 5 2 1 2 1 3 0 2 2 4 1 6 5 6 1 5 2 3 6 6 4 2 1 2 1 6 3 5 9 0 3 2 1 1 1 3 2 1 5 3 9 3 2 3 4 2 3 1 2 3 3 0 2 5 2 3 3 3 3 4 7 2 1 1 2 0 5 2 10 3 2 1 6 3 5 1 2 1 1...
result:
wrong answer 2nd lines differ - expected: '0', found: '1'