QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#140434#3002. Busy BoardKLPP#WA 7ms13316kbC++201.9kb2023-08-15 22:04:262023-08-15 22:04:29

Judging History

你现在查看的是最新测评结果

  • [2023-08-15 22:04:29]
  • 评测
  • 测评结果:WA
  • 用时:7ms
  • 内存:13316kb
  • [2023-08-15 22:04:26]
  • 提交

answer

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
typedef long long int lld;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define trav(a,v) for(auto a:v)
string table1[1000];
string table2[1000];
vector<int> nei[2000];
bool visited[2000];
void DFS(int node){
	visited[node]=true;
	trav(a,nei[node]){
		if(!visited[a])DFS(a);
	}
}
bool lockedr[1000];
bool lockedc[1000];
void solve(){
	int r,c;
	cin>>r>>c;
	rep(i,0,r){
		cin>>table1[i];
	}
	rep(i,0,r){
		cin>>table2[i];
	}
	rep(i,0,r+c)visited[i]=false;
	rep(i,0,r){
		rep(j,0,c){
			if(table2[i][j]=='X'){
				nei[i].push_back(j+r);
				nei[j+r].push_back(i);
			}
		}
	}
	rep(i,0,r){
		int cnt=0;
		rep(j,0,c){
			cnt+=(table2[i][j]=='X');
		}
		if(cnt>=2)DFS(i);
	}
	rep(j,0,c){
		int cnt=0;
		rep(i,0,r){
			cnt+=(table2[i][j]=='X');
		}
		if(cnt>=2)DFS(j+r);
	}
	rep(i,0,r)lockedr[i]=visited[i];
	rep(j,0,c)lockedc[j]=visited[j+r];
	rep(i,0,r){
		rep(j,0,c){
			if(lockedr[i] && lockedc[j]){
				if(table1[i][j]!=table2[i][j]){
					cout<<"0\n";
					return;
				}
			}
		}
	}
	int totorg[2]={0,0};
	int totfin[2]={0,0};
	rep(i,0,r){
		rep(j,0,c){
			if(!lockedr[i] && !lockedc[j]){
				if(table1[i][j]=='X')totorg[0]++;
				else totorg[1]++;
				if(table2[i][j]=='X')totfin[0]++;
				else totfin[1]++;
			}
		}
	}
	rep(i,0,2){
		if((totorg[i]==0) ^ (totfin[i]==0)){
			cout<<"0\n";
			return;
		}
	}
	if(totorg[0]==0 || totorg[1]==0){
		//no splat
		rep(i,0,r){
			rep(j,0,c){
				if(table1[i][j]!=table2[i][j]){
					cout<<"0\n";
					return;
				}
			}
		}
	}
	cout<<"1\n";
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int tt=1;
	//cin>>tt;
	while(tt--){
		solve();
	}
}

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 5436kb

input:

769 998
OOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOO...

output:

0

result:

ok answer is 0

Test #2:

score: 0
Accepted
time: 0ms
memory: 5672kb

input:

977 998
OOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOO...

output:

0

result:

ok answer is 0

Test #3:

score: 0
Accepted
time: 7ms
memory: 13316kb

input:

941 973
XOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXOXXXXXXXOXXXXXXXOXXOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...

output:

1

result:

ok answer is 1

Test #4:

score: 0
Accepted
time: 2ms
memory: 4220kb

input:

65 983
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...

output:

0

result:

ok answer is 0

Test #5:

score: 0
Accepted
time: 1ms
memory: 3884kb

input:

50 201
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXOXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...

output:

0

result:

ok answer is 0

Test #6:

score: -100
Wrong Answer
time: 5ms
memory: 4948kb

input:

949 507
OXOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOXOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO...

output:

0

result:

wrong answer expected 1, found 0