QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#602025 | #8935. Puzzle: Easy as Scrabble | racxa# | WA | 0ms | 3724kb | C++14 | 4.0kb | 2024-09-30 17:55:49 | 2024-09-30 17:55:51 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define ff first
#define ss second
using namespace std;
char g[1010][1010];
pair<int,char> pref[1010];
pair<int,char> suf[1010];
pair<int,char> top[1010];
pair<int,char> bot[1010];
int main() {
ios_base::sync_with_stdio(false); cin.tie(0);
int n,m;
cin>>n>>m;
for(int i=0;i<=n+1;i++) {
for(int j=0;j<=m+1;j++) {
cin>>g[i][j];
}
}
int indic=0;
for(int i=1;i<=n;i++) {
pref[i].ff=m+1;
pref[i].ss='.';
if(g[i][0]=='.') {
pref[i].ff=0;
pref[i].ss='.';
}
else {
for(int j=1;j<=m;j++) {
if(g[i][j]=='.') {
pref[i].ff=j;
pref[i].ss=g[i][0];
break;
}
}
}
suf[i].ff=0;
suf[i].ss='.';
if(g[i][m+1]=='.') {
suf[i].ff=m+1;
suf[i].ss='.';
}
else {
for(int j=m;j>=1;j--) {
if(g[i][j]=='.') {
suf[i].ff=j;
suf[i].ss=g[i][m+1];
break;
}
}
}
if(pref[i].ff>=suf[i].ff&&pref[i].ss!=suf[i].ss) {
indic=1;
break;
}
}
if(indic==1) {
cout<<"NO";
return 0;
}
for(int j=1;j<=m;j++) {
top[j].ff=n+1;
top[j].ss='.';
if(g[0][j]=='.') {
top[j].ff=0;
top[j].ss='.';
}
else {
for(int i=1;i<=n;i++) {
if(g[i][j]=='.') {
if(j<=pref[i].ff||j>=suf[i].ff) {
if(j<=pref[i].ff&&g[0][j]==g[i][0]||g[i][0]=='.') {
top[j].ff=i;
top[j].ss=g[0][j];
break;
}
if(j>=suf[i].ff&&g[0][j]==g[i][m+1]||g[i][m+1]=='.') {
top[j].ff=i;
top[j].ss=g[0][j];
break;
}
}
else {
top[j].ss=g[0][j];
top[j].ff=i;
break;
}
}
}
}
bot[j].ff=0;
bot[j].ss='.';
if(g[n+1][j]=='.') {
bot[j].ff=n+1;
bot[j].ss='.';
}
else {
for(int i=n;i>=1;i--) {
if(g[i][j]=='.') {
if(j<=pref[i].ff||j>=suf[i].ff){
if(j<=pref[i].ff&&g[n+1][j]==g[i][0]||g[i][0]=='.') {
bot[j].ff=i;
bot[j].ss=g[n+1][j];
break;
}
if(j>=suf[i].ff&&g[n+1][j]==g[i][m+1]||g[i][m+1]=='.') {
top[j].ff=i;
top[j].ss=g[n+1][j];
break;
}
}
else {
top[j].ss=g[n+1][j];
top[j].ff=i;
break;
}
}
}
}
if(top[j].ff>=bot[j].ff&&top[j].ss!=bot[j].ss) {
indic=1;
break;
}
}
if(indic==1) {
cout<<"NO";
return 0;
}
for(int i=1;i<=n;i++) {
g[i][pref[i].ff]=pref[i].ss;
g[i][suf[i].ff]=suf[i].ss;
}
for(int j=1;j<=m;j++) {
g[top[j].ff][j]=top[j].ss;
g[bot[j].ff][j]=bot[j].ss;
}
cout<<"YES"<<endl;
for(int i=1;i<=n;i++) {
for(int j=1;j<=m;j++) {
if(g[i][j]=='x') {
g[i][j]='.';
}
cout<<g[i][j];
}
cout<<endl;
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3724kb
input:
5 5 .CBA... ....x.. ..x...C A.....B B..x..A C...... .......
output:
YES CBA.. ....C A...B B...A C....
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 0ms
memory: 3656kb
input:
1 2 .... Nx.. ..O.
output:
NO
result:
ok Correct.
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3572kb
input:
5 5 .U.N.X. U....xX Ox....X M...xxN Vx....S Ix.x..X ..IBHX.
output:
NO
result:
wrong answer Jury has answer but participant has not.