QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#140435 | #3002. Busy Board | KLPP# | WA | 18ms | 13448kb | C++20 | 2.0kb | 2023-08-15 22:10:09 | 2023-08-15 22:10:12 |
Judging History
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]++;
}
}
}
if(totorg[0]+totorg[1]==1){
if(totorg[1]==1){
cout<<"1\n";
return;
}
}
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: 7ms
memory: 5544kb
input:
769 998 OOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOO...
output:
0
result:
ok answer is 0
Test #2:
score: 0
Accepted
time: 3ms
memory: 5676kb
input:
977 998 OOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOO...
output:
0
result:
ok answer is 0
Test #3:
score: 0
Accepted
time: 18ms
memory: 13448kb
input:
941 973 XOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXOXXXXXXXOXXXXXXXOXXOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...
output:
1
result:
ok answer is 1
Test #4:
score: 0
Accepted
time: 2ms
memory: 4404kb
input:
65 983 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...
output:
0
result:
ok answer is 0
Test #5:
score: 0
Accepted
time: 1ms
memory: 3724kb
input:
50 201 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXOXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...
output:
0
result:
ok answer is 0
Test #6:
score: -100
Wrong Answer
time: 3ms
memory: 4912kb
input:
949 507 OXOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOXOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO...
output:
0
result:
wrong answer expected 1, found 0