QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#86822 | #3002. Busy Board | fzj2007 | WA | 12ms | 11332kb | C++14 | 2.4kb | 2023-03-11 09:25:28 | 2023-03-11 09:25:31 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
namespace IO{
template<typename T>inline bool read(T &x){
x=0;
char ch=getchar();
bool flag=0,ret=0;
while(ch<'0'||ch>'9') flag=flag||(ch=='-'),ch=getchar();
while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar(),ret=1;
x=flag?-x:x;
return ret;
}
template<typename T,typename ...Args>inline bool read(T& a,Args& ...args){
return read(a)&&read(args...);
}
template<typename T>void prt(T x){
if(x>9) prt(x/10);
putchar(x%10+'0');
}
template<typename T>inline void put(T x){
if(x<0) putchar('-'),x=-x;
prt(x);
}
template<typename T>inline void put(char ch,T x){
if(x<0) putchar('-'),x=-x;
prt(x);
putchar(ch);
}
template<typename T,typename ...Args>inline void put(T a,Args ...args){
put(a);
put(args...);
}
template<typename T,typename ...Args>inline void put(const char ch,T a,Args ...args){
put(ch,a);
put(ch,args...);
}
inline void put(string s){
for(int i=0,sz=s.length();i<sz;i++) putchar(s[i]);
}
inline void put(const char* s){
for(int i=0,sz=strlen(s);i<sz;i++) putchar(s[i]);
}
inline bool getch(){
char ch=getchar();
while(ch!='O'&&ch!='X') ch=getchar();
return ch=='X';
}
}
using namespace IO;
#define N 1005
int n,m,A[N][N],B[N][N],L[N][3],R[N][3];
bool vis[N<<1],flag;
int main(){
read(n,m);
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++) A[i][j]=getch();
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++) B[i][j]=getch(),L[i][B[i][j]]++,R[i][B[i][j]]++;
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++) flag=flag&&A[i][j]==B[i][j];
if(flag) return puts("1"),0;
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++) flag=flag||!A[i][j];
if(!flag) return puts("0"),0;
do{
flag=0;
for(int x=1;x<=n;x++){
for(int y=1;y<=m;y++){
if((vis[x]&&vis[y+n])||!B[x][y]) continue;
if((L[x][1]==1&&R[y][1]==1&&B[x][y]==1)||(L[x][1]==0&&R[y][1]==0&&B[x][y]==2)){
vis[x]=vis[y+n]=flag=1;
for(int i=1;i<=m;i++){
L[x][B[x][i]]--,R[i][B[x][i]]--;
B[x][i]=2;
L[x][B[x][i]]++,R[i][B[x][i]]++;
}
for(int i=1;i<=n;i++){
R[y][B[i][y]]--,L[i][B[i][y]]--;
B[i][y]=2;
R[y][B[i][y]]++,L[i][B[i][y]]++;
}
}
}
}
}while(flag);
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
if(B[i][j]!=2&&B[i][j]!=A[i][j]) return puts("0"),0;
puts("1");
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 12ms
memory: 10440kb
input:
769 998 OOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOO...
output:
0
result:
ok answer is 0
Test #2:
score: 0
Accepted
time: 1ms
memory: 11332kb
input:
977 998 OOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOO...
output:
0
result:
ok answer is 0
Test #3:
score: -100
Wrong Answer
time: 5ms
memory: 11008kb
input:
941 973 XOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXOXXXXXXXOXXXXXXXOXXOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...
output:
0
result:
wrong answer expected 1, found 0