QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#139133 | #3002. Busy Board | karuna# | WA | 146ms | 5496kb | C++17 | 2.2kb | 2023-08-12 18:02:38 | 2023-08-12 18:02:41 |
Judging History
answer
#include <bits/stdc++.h>
#define ff first
#define ss second
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
int main() {
cin.tie(0); ios_base::sync_with_stdio(0);
int n, m; cin >> n >> m;
bool A[n][m], B[n][m];
for(int i = 0; i < n; ++i) for(int j = 0; j < m; ++j)
{
char c; cin >> c;
A[i][j] = (c == 'X');
}
for(int i = 0; i < n; ++i) for(int j = 0; j < m; ++j)
{
char c; cin >> c;
B[i][j] = (c == 'X');
}
queue<pii> Q;
for(int i = 0; i < n; ++i)
{
int cnt = 0;
for(int j = 0; j < m; ++j)
if(B[i][j]) ++cnt;
if(cnt >= 2) Q.push({i, 0});
}
for(int j = 0; j < m; ++j)
{
int cnt = 0;
for(int i = 0; i < n; ++i)
if(B[i][j]) ++cnt;
if(cnt >= 2) Q.push({j, 1});
}
bool oX[n]{}, oY[m]{};
bool xX[n]{}, xY[m]{};
while(Q.size())
{
auto [x, c] = Q.front(); Q.pop();
if(c == 0)
{
if(xX[x]) continue;
xX[x] = true;
set<int> S;
for(int j = 0; j < m; ++j) if(A[x][j]) S.insert(j);
for(int j = 0; j < m; ++j) if(B[x][j])
{
if(!S.count(j)) return !(cout << 0);
S.erase(j);
oY[j] = true;
}
for(auto j : S) Q.push({j, 1});
}
else
{
if(xY[x]) continue;
xY[x] = true;
set<int> S;
for(int i = 0; i < n; ++i) if(A[i][x]) S.insert(i);
for(int i = 0; i < n; ++i) if(B[i][x])
{
if(!S.count(i)) return !(cout << 0);
S.erase(i);
oX[i] = true;
}
for(auto i : S) Q.push({i, 0});
}
}
for(int i = 0; i < n; ++i) if(oX[i] && xX[i]) return !(cout << 0);
for(int j = 0; j < m; ++j) if(oY[j] && xY[j]) return !(cout << 0);
int icnt = 0, fcnt = 0, xcnt = n, ycnt = m;
for(int i = 0; i < n; ++i) if(xX[i]) --xcnt;
for(int j = 0; j < m; ++j) if(xY[j]) --ycnt;
for(int i = 0; i < n; ++i) if(!xX[i])
{
for(int j = 0; j < m; ++j) if(!xY[j])
{
if(A[i][j]) ++icnt;
if(B[i][j]) ++fcnt;
}
}
if(xcnt == 0 || ycnt == 0) return !(cout << 1);
if((icnt != xcnt * ycnt) && (fcnt != 0)) return !(cout << 1);
if(icnt != fcnt) return !(cout << 0);
for(int i = 0; i < n; ++i) if(!xX[i] && oX[i]) return !(cout << 0);
for(int j = 0; j < m; ++j) if(!xY[j] && oY[j]) return !(cout << 0);
cout << 1;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 15ms
memory: 5000kb
input:
769 998 OOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOO...
output:
0
result:
ok answer is 0
Test #2:
score: 0
Accepted
time: 12ms
memory: 5384kb
input:
977 998 OOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOO...
output:
0
result:
ok answer is 0
Test #3:
score: -100
Wrong Answer
time: 146ms
memory: 5496kb
input:
941 973 XOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXOXXXXXXXOXXXXXXXOXXOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...
output:
0
result:
wrong answer expected 1, found 0