QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#335387 | #4079. 칠하기 | bachbeo2007 | 0 | 0ms | 3804kb | C++20 | 1.7kb | 2024-02-23 11:34:05 | 2024-02-23 11:34:05 |
answer
#include <bits/stdc++.h>
using namespace std;
int dx[]={0,0,1,-1},
dy[]={1,-1,0,0};
int yellowblue(int N, int M, vector<std::string> V)
{
int check=1;
int cnt=0;
for(int i=0;i<N;i++){
int p=0;
auto f = [&](int l,int r){
if(l>r) return;
int c=1;
for(int j=l;j<=r;j++){
if(!i || V[i-1][j]=='#') c=0;
if(i==N-1 || V[i+1][j]=='#') c=0;
}
cnt+=c;
};
for(int j=0;j<M;j++){
if(V[i][j]=='#') f(p,j-1),p=j+1;
}
f(p,M-1);
}
for(int i=0;i<M;i++){
int p=0;
auto f = [&](int l,int r){
if(l>r) return;
int c=1;
for(int j=l;j<=r;j++){
if(!i || V[j][i-1]=='#') c=0;
if(i==M-1 || V[j][i+1]=='#') c=0;
}
cnt+=c;
};
for(int j=0;j<N;j++) if(V[j][i]=='#') f(p,j-1),p=j+1;
f(p,N-1);
}
check&=(cnt<=1);
vector<vector<bool>> vis(N,vector<bool>(M,false));
function<void(int,int)> dfs = [&](int x,int y){
vis[x][y]=true;
for(int t=0;t<4;t++){
int xt=x+dx[t],yt=y+dy[t];
if(xt<0 || xt>=N || yt<0 || yt>=M || V[xt][yt]=='#' || vis[xt][yt]) continue;
dfs(xt,yt);
}
};
bool done=false;
for(int i=0;i<N;i++){
for(int j=0;j<M;j++){
if(V[i][j]=='.'){
dfs(i,j);
done=true;
break;
}
}
if(done) break;
}
for(int i=0;i<N;i++) for(int j=0;j<M;j++) if(!vis[i][j] && V[i][j]=='.') check=0;
return check;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 30
Accepted
time: 0ms
memory: 3512kb
input:
3 5 ...## ....# #.#..
output:
1
result:
ok single line: '1'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3788kb
input:
4 4 ..#. #... ...# .#..
output:
1
result:
ok single line: '1'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3532kb
input:
15 15 #######..###### ######....##### #####......#### ####........### ###..........## ##............# #.............. ............... #.............# ##...........## ###.........### ####.......#### #####.....##### ######...###### #######.#######
output:
1
result:
ok single line: '1'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3524kb
input:
16 16 ########..###### #######....##### ######......#### #####........### ####..........## ###............# ##.............. ................ ##.............# ###...........## ####.........### #####.......#### ######.....##### #######...###### ########.####### ########.#######
output:
0
result:
ok single line: '0'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3792kb
input:
15 16 ########..###### #######....##### ######......#### #####........### ####..........## ###............# ##.............. ................ ##.............# ###...........## ####.........### #####.......#### ######.....##### #######...###### ########.#######
output:
1
result:
ok single line: '1'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3520kb
input:
10 10 ..#...#... ...#...#.. .#...#...# #...#...#. ..#...#... ...#...#.. .#...#...# #...#...#. ..#...#... ...#...#..
output:
1
result:
ok single line: '1'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
10 10 ..#...#... ...#...#.. .#..#....# #.......#. .......#.. ..#....... .#.......# #....#..#. ..#...#... ...#...#..
output:
1
result:
ok single line: '1'
Test #8:
score: -30
Wrong Answer
time: 0ms
memory: 3804kb
input:
20 20 ..#...#...#...#...#. #..#...#...#...#.... ....#...#...#...#..# ..#..#...#...#....#. .#....#...#...#..#.. #...#..#...#....#... ...#....#...#..#...# ..#...#..#....#...#. .#...#....#..#...#.. #...#...#...#...#... ...#...#...#...#...# ..#...#..#....#...#. .#...#....#..#...#.. #...#..#...#....#... ...
output:
1
result:
wrong answer 1st lines differ - expected: '0', found: '1'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%