QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#310335 | #6398. Puzzle: Tapa | PlentyOfPenalty# | WA | 1ms | 3832kb | C++20 | 3.2kb | 2024-01-21 11:21:39 | 2024-01-21 11:21:40 |
Judging History
answer
#include<bits/stdc++.h>
#define QUIT exit((puts("NO"),0))
using namespace std;
const int N=100;
int n,m,mp[N+10][N+10],tv[N+10][N+10],fl;
char tmp[N+10][N+10],prt[N+10][N+10];
void Solve(int xl,int yl,int xr,int yr){
if(xr==xl){
if(yr==yl){
if(mp[xl][yl])QUIT;
return;
}
for(int i=yl+1;i<yr;i+=2){
if(mp[xl][i-1]){
prt[xl][i]='.';
if(!mp[xl][i+1])QUIT;
mp[xl][i+1]=0;
}else prt[xl][i]='#';
}
return;
}
if(xr-xl==2)for(int j=yl+1;j<yr;++j)prt[xl+1][j]='#';
else{
for(int i=xl+1;i<xr;++i)prt[i][yl+1]=prt[i][yr-1]='#';
for(int i=yl+1;i<yr;++i)prt[xl+1][i]=prt[xr-1][i]='#';
Solve(xl+2,yl+2,xr-2,yr-2);
}
for(int i=xl;i<=xr;++i)tv[i][yl]=mp[i][yl],tv[i][yr]=mp[i][yr];
for(int i=yl;i<=yr;++i)tv[xl][i]=mp[xl][i],tv[xr][i]=mp[xr][i];
for(int i=xl+1;i<xr;i+=2){
if(tv[i-1][yl]){
tv[i-1][yl]=0;
prt[i][yl]='.';
if(!tv[i+1][yl])goto Skip;
tv[i+1][yl]=0;
}else prt[i][yl]='#';
}
for(int i=yl+1;i<yr;i+=2){
if(tv[xr][i-1]){
tv[xr][i-1]=0;
prt[xr][i]='.';
if(!tv[xr][i+1])goto Skip;
tv[xr][i+1]=0;
}else prt[xr][i]='#';
}
for(int i=xr-1;i>xl;i-=2){
if(tv[i+1][yr]){
tv[i+1][yr]=0;
prt[i][yr]='.';
if(!tv[i+1][yr])goto Skip;
tv[i-1][yr]=0;
}else prt[i][yr]='#';
}
for(int i=yr-1;i>yl;i-=2){
if(tv[xl][i+1]){
tv[xl][i+1]=0;
prt[xl][i]='.';
if(!tv[xl][i-1])goto Skip;
tv[xl][i-1]=0;
}else prt[xl][i]='#';
}
return;
Skip:
for(int i=xl;i<=xr;++i)tv[i][yl]=mp[i][yl],tv[i][yr]=mp[i][yr];
for(int i=yl;i<=yr;++i)tv[xl][i]=mp[xl][i],tv[xr][i]=mp[xr][i];
for(int i=yl+1;i<yr;i+=2){
if(tv[xl][i-1]){
tv[xl][i-1]=0;
prt[xl][i]='.';
if(!tv[xl][i+1])QUIT;
tv[xl][i+1]=0;
}else prt[xl][i]='#';
}
for(int i=xl+1;i<xr;i+=2){
if(tv[i-1][yr]){
tv[i-1][yr]=0;
prt[i][yr]='.';
if(!tv[i+1][yr])QUIT;
tv[i+1][yr]=0;
}else prt[i][yr]='#';
}
for(int i=yr-1;i>yl;i-=2){
if(tv[xr][i+1]){
tv[xr][i+1]=0;
prt[xr][i]='.';
if(!tv[xr][i-1])QUIT;
tv[xr][i-1]=0;
}else prt[xr][i]='#';
}
for(int i=xr-1;i>xl;i-=2){
if(tv[i+1][yl]){
tv[i+1][yl]=0;
prt[i][yl]='.';
if(!tv[i-1][yl])QUIT;
tv[i-1][yl]=0;
}else prt[i][yl]='#';
}
}
int main(){
//cin.sync_with_stdio(0),cin.tie(0);
//cin>>n>>m;
scanf("%d%d",&n,&m);
if(n>m)swap(n,m),fl=1;
if(fl){
for(int i=1;i<(m<<1);++i)scanf("%s",tmp[i]+1);
for(int i=1;i<(n<<1);++i)for(int j=1;j<(m<<1);++j)mp[i][j]=tmp[j][i]-'0',prt[i][j]=tmp[j][i];
}else{
for(int i=1;i<(n<<1);++i)scanf("%s",tmp[i]+1);
for(int i=1;i<(n<<1);++i)for(int j=1;j<(m<<1);++j)mp[i][j]=tmp[i][j]-'0',prt[i][j]=tmp[i][j];
}
for(int i=1;i<(n<<1);i+=2)for(int j=1;j<(m<<1);j+=2)mp[i][j]=(mp[i][j]==2||mp[i][j]==4||mp[i][j]==7);
Solve(1,1,(n<<1)-1,(m<<1)-1);
puts("YES");
if(fl){
for(int i=1;i<(m<<1);++i){
for(int j=1;j<(n<<1);++j)putchar(prt[j][i]);
putchar('\n');
}
}else{
for(int i=1;i<(n<<1);++i){
for(int j=1;j<(m<<1);++j)putchar(prt[i][j]);
putchar('\n');
}
}
return 0;
}
/*
3 3
2.4.3
.....
5.8.5
.....
3.5.3
3 3
3.4.3
.....
5.7.5
.....
3.5.3
2 3
2.4.2
.....
2.4.2
3 2
3.3
...
5.5
...
3.3
3 4
3.5.5.3
.......
5.8.8.5
.......
3.5.5.3
*/
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3616kb
input:
3 3 2.4.3 ..... 5.8.5 ..... 3.5.3
output:
YES 2.4#3 ##### 5#8#5 ##### 3#5#3
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
3 3 3.4.3 ..... 5.7.5 ..... 3.5.3
output:
NO
result:
ok Correct.
Test #3:
score: 0
Accepted
time: 1ms
memory: 3752kb
input:
2 2 2.2 ... 2.2
output:
YES 2.2 ### 2.2
result:
ok Correct.
Test #4:
score: 0
Accepted
time: 1ms
memory: 3736kb
input:
2 50 2.4.4.4.4.5.5.5.5.5.5.5.5.4.5.5.4.4.5.5.5.5.4.5.5.5.5.5.4.4.5.4.5.5.5.5.5.5.5.5.5.5.5.4.4.5.5.4.5.3 ................................................................................................... 2.5.5.4.4.5.5.5.4.4.5.5.5.4.5.5.5.5.5.5.5.5.4.4.4.5.5.5.5.5.5.4.4.4.5.5.5.5.5.5.5.4.4.5.5.5.5.4...
output:
NO
result:
ok Correct.
Test #5:
score: 0
Accepted
time: 0ms
memory: 3816kb
input:
2 50 2.4.4.5.5.5.5.5.5.5.5.5.4.4.5.5.5.5.4.4.5.5.4.4.5.5.5.4.5.4.4.4.5.4.4.5.4.4.5.5.5.5.4.4.5.5.5.5.5.2 ................................................................................................... 3.5.4.5.5.5.5.5.5.5.5.5.5.5.4.5.5.5.5.4.5.5.5.5.4.4.5.4.5.4.5.5.5.5.5.4.4.5.5.5.4.4.5.5.5.5.5.4...
output:
NO
result:
ok Correct.
Test #6:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
50 2 3.2 ... 5.4 ... 5.5 ... 4.4 ... 5.5 ... 5.5 ... 5.5 ... 5.5 ... 5.5 ... 5.5 ... 5.5 ... 5.4 ... 5.4 ... 5.5 ... 5.5 ... 5.5 ... 5.5 ... 5.5 ... 5.4 ... 5.4 ... 5.4 ... 5.4 ... 4.4 ... 5.5 ... 5.5 ... 4.4 ... 5.4 ... 5.4 ... 5.5 ... 4.5 ... 4.5 ... 5.5 ... 5.5 ... 5.5 ... 5.5 ... 5.5 ... 5.5 ......
output:
NO
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 0ms
memory: 3764kb
input:
50 2 3.3 ... 5.4 ... 5.4 ... 5.4 ... 5.4 ... 5.5 ... 4.4 ... 4.4 ... 5.5 ... 4.4 ... 5.5 ... 5.5 ... 5.5 ... 5.5 ... 4.5 ... 5.5 ... 5.5 ... 5.4 ... 5.4 ... 5.5 ... 5.4 ... 5.5 ... 5.4 ... 5.4 ... 5.5 ... 5.5 ... 4.5 ... 4.5 ... 4.5 ... 4.5 ... 5.5 ... 5.4 ... 5.4 ... 5.5 ... 5.5 ... 4.4 ... 4.4 ......
output:
NO
result:
ok Correct.
Test #8:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
3 50 3.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.4.4.5.5.5.5.4.4.5.5.5.5.5.5.5.5.4.4.5.5.4.4.5.4.4.5.3 ................................................................................................... 4.8.8.8.8.8.8.8.8.8.8.8.8.8.8.7.7.7.7.7.7.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.7.7.8...
output:
YES 3#5#5#5#5#5#5#5#5#5#5#5#5#5#5#5#5#5#5#5#5#5#5#4.4#5#5#5#5#4.4#5#5#5#5#5#5#5#5#4.4#5#5#4.4#5#4.4#5#3 ################################################################################################### 4#8#8#8#8#8#8#8#8#8#8#8#8#8#8#7.7#7.7#7.7#8#8#8#8#8#8#8#8#8#8#8#8#8#8#8#8#8#8#8#8#8#8#8#8#7.7#8#...
result:
ok Correct.
Test #9:
score: 0
Accepted
time: 0ms
memory: 3824kb
input:
3 50 2.4.4.4.5.4.4.4.4.4.4.5.5.4.4.5.5.4.4.5.5.5.4.4.5.5.5.4.4.5.5.4.4.4.4.5.5.5.5.5.5.4.4.5.5.5.5.4.4.3 ................................................................................................... 5.7.7.8.7.7.7.7.8.8.8.8.7.7.8.7.7.8.8.8.8.7.7.8.8.8.7.7.8.7.7.8.8.8.8.7.7.8.8.7.7.8.8.8.7.7.8.8...
output:
YES 2.4#4.4#5#4.4#4.4#4.4#5#5#4.4#5#5#4.4#5#5#5#4.4#5#5#5#4.4#5#5#4.4#4.4#5#5#5#5#5#5#4.4#5#5#5#5#4.4#3 ################################################################################################### 5#7.7#8#7.7#7.7#8#8#8#8#7.7#8#7.7#8#8#8#8#7.7#8#8#8#7.7#8#7.7#8#8#8#8#7.7#8#8#7.7#8#8#8#7.7#8#8#...
result:
ok Correct.
Test #10:
score: 0
Accepted
time: 0ms
memory: 3832kb
input:
50 3 3.5.3 ..... 5.8.5 ..... 5.8.5 ..... 5.8.5 ..... 5.8.5 ..... 5.8.5 ..... 5.8.4 ..... 5.8.4 ..... 4.8.5 ..... 4.7.5 ..... 5.7.5 ..... 5.8.5 ..... 5.8.4 ..... 5.8.4 ..... 5.8.5 ..... 5.8.5 ..... 5.8.5 ..... 5.8.5 ..... 5.8.5 ..... 4.8.5 ..... 4.7.5 ..... 5.7.5 ..... 5.8.5 ..... 5.8.5 ..... 5.8.5 ....
output:
YES 3#5#3 ##### 5#8#5 ##### 5#8#5 ##### 5#8#5 ##### 5#8#5 ##### 5#8#5 ##### 5#8#4 ####. 5#8#4 ##### 4#8#5 .#### 4#7#5 ##.## 5#7#5 ##### 5#8#5 ##### 5#8#4 ####. 5#8#4 ##### 5#8#5 ##### 5#8#5 ##### 5#8#5 ##### 5#8#5 ##### 5#8#5 ##### 4#8#5 .#### 4#7#5 ##.## 5#7#5 ##### 5#8#5 ##### 5#8#5 ##### 5#8#5 ##...
result:
ok Correct.
Test #11:
score: 0
Accepted
time: 0ms
memory: 3704kb
input:
50 3 2.4.3 ..... 4.8.5 ..... 4.8.5 ..... 5.8.5 ..... 4.7.4 ..... 4.7.4 ..... 4.8.5 ..... 4.8.4 ..... 5.8.4 ..... 4.7.5 ..... 4.7.5 ..... 5.8.5 ..... 5.8.5 ..... 5.8.4 ..... 5.8.4 ..... 5.8.5 ..... 5.8.5 ..... 5.7.5 ..... 5.7.5 ..... 5.8.5 ..... 5.8.5 ..... 5.8.5 ..... 4.8.5 ..... 4.7.5 ..... 4.7.4 ....
output:
YES 2.4#3 ##### 4#8#5 .#### 4#8#5 ##### 5#8#5 ##### 4#7#4 .#.#. 4#7#4 ##### 4#8#5 .#### 4#8#4 ####. 5#8#4 ##### 4#7#5 .#.## 4#7#5 ##### 5#8#5 ##### 5#8#5 ##### 5#8#4 ####. 5#8#4 ##### 5#8#5 ##### 5#8#5 ##### 5#7#5 ##.## 5#7#5 ##### 5#8#5 ##### 5#8#5 ##### 5#8#5 ##### 4#8#5 .#### 4#7#5 ##.## 4#7#4 .#...
result:
ok Correct.
Test #12:
score: -100
Wrong Answer
time: 0ms
memory: 3652kb
input:
10 10 2.4.4.4.5.5.4.4.5.2 ................... 5.7.8.8.7.8.7.7.8.4 ................... 4.7.8.8.7.8.8.8.8.5 ................... 4.8.8.8.7.7.8.8.8.4 ................... 5.8.7.7.7.7.8.8.7.4 ................... 4.7.7.8.8.8.8.8.7.4 ................... 4.8.7.8.8.7.7.7.8.4 ................... 5.8.7.8.8.7.8....
output:
NO
result:
wrong answer Jury has answer but participant has not.