QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#86821 | #3002. Busy Board | fzj2007 | WA | 8ms | 11132kb | C++14 | 2.8kb | 2023-03-11 09:21:19 | 2023-03-11 09:21:21 |
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;
queue<pair<int,int> > q;
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
if(B[i][j]==1&&L[i][1]==1&&R[j][1]==1) q.push(make_pair(i,j));
while(!q.empty()){
int x=q.front().first,y=q.front().second;
q.pop();
if(vis[x]&&vis[y+n]) continue;
vis[x]=vis[y+n]=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]]++;
}
for(int i=1;i<=m;i++){
if(vis[x]&&vis[i+n]) continue;
if(L[x][1]==1&&R[i][1]==1&&B[x][i]==1) q.push(make_pair(x,i));
else if(L[x][1]==0&&R[i][1]==0&&B[x][i]==2) q.push(make_pair(x,i));
}
for(int i=1;i<=n;i++){
if(vis[i]&&vis[y+n]) continue;
if(L[i][1]==1&&R[y][1]==1&&B[i][y]==1) q.push(make_pair(i,y));
else if(L[i][1]==0&&R[y][1]==0&&B[i][y]==2) q.push(make_pair(i,y));
}
}
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;
}
详细
Test #1:
score: 100
Accepted
time: 7ms
memory: 10580kb
input:
769 998 OOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOO...
output:
0
result:
ok answer is 0
Test #2:
score: 0
Accepted
time: 8ms
memory: 11132kb
input:
977 998 OOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOO...
output:
0
result:
ok answer is 0
Test #3:
score: -100
Wrong Answer
time: 8ms
memory: 11100kb
input:
941 973 XOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXOXXXXXXXOXXXXXXXOXXOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...
output:
0
result:
wrong answer expected 1, found 0