QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#335616#4079. 칠하기socpite100 ✓184ms109208kbC++202.6kb2024-02-23 17:10:212024-02-23 17:10:23

Judging History

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

  • [2024-02-23 17:10:23]
  • 评测
  • 测评结果:100
  • 用时:184ms
  • 内存:109208kb
  • [2024-02-23 17:10:21]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

const int maxn = 1e3+5;
int LR[maxn][maxn], UD[maxn][maxn];
int vis[maxn*maxn*2], scc[maxn*maxn*2], d[maxn*maxn*2];

vector<int> g[maxn*maxn*2];
vector<int> rg[maxn*maxn*2];
vector<int> cg[maxn*maxn*2];

vector<int> ord;
int scnt = 0;
int cnt = 0;

void dfs(int x){
    vis[x] = 1;
    for(auto v: g[x]){
        if(vis[v])continue;
        dfs(v);
    }
    ord.push_back(x);
}

void dfs2(int x){
    scc[x] = scnt;
    for(auto v: rg[x]){
        if(scc[v])continue;
        dfs2(v);
    }
}

int solve() {
    for(int i = 1; i <= cnt; i++){
        if(!vis[i])dfs(i);
        for(auto v: g[i])rg[v].push_back(i);
    }
    reverse(ord.begin(), ord.end());
    for(auto v: ord){
        if(scc[v])continue;
        scnt++;
        dfs2(v);
    }
    for(int i = 1; i <= cnt; i++){
        for(auto v: g[i]){
            if(scc[i] == scc[v])continue;
            cg[scc[i]].push_back(scc[v]);
            d[scc[v]]++;
        }
    }
    queue<int> q;
    for(int i = 1; i <= scnt; i++){
        if(!d[i])q.push(i);
    }
    vector<int> topo_ord;
    while(!q.empty()){
        auto x = q.front();
        q.pop();
        topo_ord.push_back(x);
        for(auto v: cg[x]){
            d[v]--;
            if(!d[v])q.push(v);
        }
    }
    for(int i = 0; i + 1 < topo_ord.size(); i++){
        bool chk = 0;
        for(auto v: cg[topo_ord[i]])if(v == topo_ord[i+1])chk = 1;
        if(!chk)return 0;
    }
    return 1;
}

int yellowblue(int N, int M, vector<string> V){
    int prv = -1;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < M; j++){
            if(V[i][j] == '#')prv = -1;
            else {
                if(prv == -1)prv = ++cnt;
                LR[i][j] = prv;
            }
        }
        prv = -1;
    }
    prv = -1;
    for(int i = 0; i < M; i++){
        for(int j = 0; j < N; j++){
            if(V[j][i] == '#')prv = -1;
            else {
                if(prv == -1)prv = ++cnt;
                UD[j][i] = prv;
            }
        }
        prv = -1;
    }
    for(int i = 0; i < N; i++){
        for(int j = 0; j < M; j++){
            if(V[i][j] == '#')continue;
            if(i == 0 || V[i-1][j] == '#' || i == N-1 || V[i+1][j] == '#')g[UD[i][j]].push_back(LR[i][j]);
            if(j == 0 || V[i][j-1] == '#' || j == M-1 || V[i][j+1] == '#')g[LR[i][j]].push_back(UD[i][j]);
        }
    }
    return solve();
}

// int main(){
//     int N, M;
//     cin >> N >> M;
//     vector<string> V(N);
//     for(auto &v: V)cin >> v;
//     cout << yellowblue(N, M, V);
// }

詳細信息

Subtask #1:

score: 30
Accepted

Test #1:

score: 30
Accepted
time: 3ms
memory: 9752kb

input:

3 5
...##
....#
#.#..

output:

1

result:

ok single line: '1'

Test #2:

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

input:

4 4
..#.
#...
...#
.#..

output:

1

result:

ok single line: '1'

Test #3:

score: 0
Accepted
time: 6ms
memory: 7720kb

input:

15 15
#######..######
######....#####
#####......####
####........###
###..........##
##............#
#..............
...............
#.............#
##...........##
###.........###
####.......####
#####.....#####
######...######
#######.#######

output:

1

result:

ok single line: '1'

Test #4:

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

input:

16 16
########..######
#######....#####
######......####
#####........###
####..........##
###............#
##..............
................
##.............#
###...........##
####.........###
#####.......####
######.....#####
#######...######
########.#######
########.#######

output:

0

result:

ok single line: '0'

Test #5:

score: 0
Accepted
time: 6ms
memory: 9956kb

input:

15 16
########..######
#######....#####
######......####
#####........###
####..........##
###............#
##..............
................
##.............#
###...........##
####.........###
#####.......####
######.....#####
#######...######
########.#######

output:

1

result:

ok single line: '1'

Test #6:

score: 0
Accepted
time: 3ms
memory: 7628kb

input:

10 10
..#...#...
...#...#..
.#...#...#
#...#...#.
..#...#...
...#...#..
.#...#...#
#...#...#.
..#...#...
...#...#..

output:

1

result:

ok single line: '1'

Test #7:

score: 0
Accepted
time: 3ms
memory: 7676kb

input:

10 10
..#...#...
...#...#..
.#..#....#
#.......#.
.......#..
..#.......
.#.......#
#....#..#.
..#...#...
...#...#..

output:

1

result:

ok single line: '1'

Test #8:

score: 0
Accepted
time: 3ms
memory: 9752kb

input:

20 20
..#...#...#...#...#.
#..#...#...#...#....
....#...#...#...#..#
..#..#...#...#....#.
.#....#...#...#..#..
#...#..#...#....#...
...#....#...#..#...#
..#...#..#....#...#.
.#...#....#..#...#..
#...#...#...#...#...
...#...#...#...#...#
..#...#..#....#...#.
.#...#....#..#...#..
#...#..#...#....#...
...

output:

0

result:

ok single line: '0'

Test #9:

score: 0
Accepted
time: 3ms
memory: 7732kb

input:

10 16
..#..#..#..#..#.
#..#..#..#..#...
.#..#..#..#....#
..#..#..#....#..
#..#..#....#..#.
.#..#....#..#..#
..#....#..#..#..
#....#..#..#..#.
...#..#..#..#..#
.#..#..#..#..#..

output:

1

result:

ok single line: '1'

Test #10:

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

input:

50 45
..#...##..##...#...#.#.#.....#..#..##..##.#..
...#.#.#.#..##...###.#..##.##.#.....#......#.
#......#.##.##....#.....#......#.#.#.#...#...
.#.#####....##.#.#..###..#.##.###..#...#....#
.....#.#.##.#..#..#...#.##...##..#...#....##.
.#..#.....##..###...##....##..#...#.##.###...
..#.#.#.#..#.##.#....

output:

0

result:

ok single line: '0'

Test #11:

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

input:

50 45
.....#...#.#..#........#.........#..........#
...##.......#...##...#..#...###.....##...#..#
.#...#...#....#....#...#.......#...#..##...#.
......#.......#.#.#.......#..#.#.#....#......
#..#..#.....#.#.......#.#..#..#...#.#....#...
.#.#....#.#...#.#...#...#.#....#........#.#..
.....##..#...##.#....

output:

0

result:

ok single line: '0'

Test #12:

score: 0
Accepted
time: 3ms
memory: 9800kb

input:

50 50
.#.......###....#.#..#....#....#...#..##....#.#.#.
............#.................#......##...........
......................................#...........
.......................................##.........
...........#...#.................................#
#......#.....#..#.........#...............

output:

0

result:

ok single line: '0'

Test #13:

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

input:

50 50
###...###..#.##..###...#..#...###....#..#.#.##.###
#....#.#......#........##......#............##....
.....#..................#........................#
...#..............................................
#................................................#
#.........................................

output:

0

result:

ok single line: '0'

Test #14:

score: 0
Accepted
time: 6ms
memory: 9776kb

input:

50 50
###.####...#.#...###...##.#...###....#..#.#.##.###
#...##.#......#........##.....##............##...#
....##..................#...................#.....
...#................#.............................
#................................................#
#.........................................

output:

0

result:

ok single line: '0'

Test #15:

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

input:

50 50
###..###...#.##..###...####...###....#..#.#.##.###
#....#.#......#........##......#............##....
....##..................#...................#....#
...#................#.............................
#................................................#
#.........................................

output:

0

result:

ok single line: '0'

Test #16:

score: 0
Accepted
time: 3ms
memory: 9804kb

input:

50 50
#.#.#.....###..#...#..###.#.....#..###.##.#.#...#.
#........###......#....#.......##......##....#....
........##......#.....#........#.......#..........
.........#...........#................##..........
#..............#.................................#
.....#..................#.................

output:

0

result:

ok single line: '0'

Test #17:

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

input:

50 50
#.#.#....####..#...#.####.#.#...#.##.#.##.#.#...#.
#........###......#...##.......##......##....#....
........##......#.....#........#.......#..........
.........#...........#................##..........
#..............#.................................#
.....#..................#.................

output:

0

result:

ok single line: '0'

Test #18:

score: 0
Accepted
time: 3ms
memory: 9796kb

input:

50 50
#.#.#....####..#..##.####.#.#...#.##.#.##.#.#...#.
#........###......#..###.......##.......#....#....
........##......#.....#........#.......#..........
.........#...........#................##..........
#..............#.................................#
.....#..................#.................

output:

0

result:

ok single line: '0'

Test #19:

score: 0
Accepted
time: 3ms
memory: 10012kb

input:

50 50
.#.###..#...#..#...##.#..##..#....#..#..##..#..#..
.....#......#.....#.#...................#........#
#.........#.......#......................#........
##..............#.................................
.....#......................#....................#
#.....#...................................

output:

0

result:

ok single line: '0'

Test #20:

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

input:

50 50
##...#..#..###.#...##.#...#..#....#..#...#.##..#..
.....#....#.#.....#.#...................#........#
#.........#.......#......................#........
#...............#.................................
#................................................#
##........................................

output:

0

result:

ok single line: '0'

Test #21:

score: 0
Accepted
time: 3ms
memory: 9888kb

input:

50 50
.#.....#.#.#.#..##.#..#.###....##.###.##.###..#.##
..##..#........##....#..#..#...#......#..#.......#
#..##.........#..........#..#..###...###..#.....##
#.......#...##.#..###..#...#.#..###...#...##.#....
.......#.##....#.##...#...##...#.....#.....##.....
#.........##..#.##.#.....#.#....#.........

output:

0

result:

ok single line: '0'

Test #22:

score: 0
Accepted
time: 6ms
memory: 9860kb

input:

50 50
##.....##...###.##.....##..#..####.#.#..##..#..##.
...#...####..#..###...#.#..#..##...#..#..##...##..
##..#..#....##..##..#....#...###.....#..###.......
.#....#.#....##....##.......#.#.....#....#......##
.....#.......#....#........#.....#...#...#.......#
.........#..#.#.#..#....#.#..#........#...

output:

0

result:

ok single line: '0'

Test #23:

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

input:

50 50
##......#...###.##.....##.##...####..##.#...#..##.
...#...##.#..##..##...##........#..#..#..##...##..
##..##.#.#..###...###....#...###.........##......#
##....#..#....#....#.#..#...#..#..#.....##......#.
.....#.#......#...##...#...#..#..#..##...#........
............#..##..#..#.###..#....#...#...

output:

0

result:

ok single line: '0'

Test #24:

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

input:

50 50
..#...#...#...#...#...#...#...#...#...#...#...#...
...#...#...#...#...#...#...#...#...#...#...#...#..
.#...#...#...#...#...#...#...#...#...#...#...#...#
#...#...#...#...#...#...#...#...#...#...#...#...#.
..#...#...#...#...#...#...#...#...#...#...#...#...
...#...#...#...#...#...#...#...#...#......

output:

0

result:

ok single line: '0'

Test #25:

score: 0
Accepted
time: 6ms
memory: 7932kb

input:

50 50
..#...#...#...#...#...#...#...#...#...#...#...#...
...#...#...#...#...#...#...#...#...#...#...#...#..
.#...#...#...#...#...#...#...#...#...#...#...#...#
#...#...#...#...#...#...#...#...#...#...#...#...#.
..#...#...#...#...#...#...#...#...#...#...#...#...
...#...#...#...#...#...#...#...#...#......

output:

1

result:

ok single line: '1'

Test #26:

score: 0
Accepted
time: 3ms
memory: 9976kb

input:

50 50
..#...#...#...#...#...#...#...#...#...#...#...#...
...#...#...#...#...#...#...#...#.....#.#...#...#..
.#...#...#...#...#...#...#...#...#...#...#...#...#
#.#.....#...#.#.....#...#...#...##..#...#...#...#.
..#...#...#...#...#...#...#...#...#...#...#...#...
...#...#...#...#...#...#...#...#...#......

output:

1

result:

ok single line: '1'

Test #27:

score: 0
Accepted
time: 3ms
memory: 10004kb

input:

50 50
..#...#...#...#...#...#...#...#...#...#...#...#...
.......#...#...#...#...#...#...#...#...#...#...#..
.#...#...#...#...#...#...#...#...#...#...#...#...#
#...#...#...#...#...#...#...#...#...#...#...#...#.
..#...#...#...#...#...#...#...#...#...#...#...#...
...#...#...#...#...#...#...#...#...#......

output:

1

result:

ok single line: '1'

Test #28:

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

input:

50 50
..#...#...#...#...#...#...#...#...#...#...#...#...
...#...#...#...#...#...#...#...#...#...#...#...#..
.#...#...#...#...#...#...#...#...#...#...#...#...#
#...#...#...#...#...#...#...#...#...#...#...#...#.
..#...#...#...#...#...#...#...#...#...#...#...#...
...#...#...#...#...#...#...#...#...#......

output:

1

result:

ok single line: '1'

Test #29:

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

input:

50 50
..#...#...#...#...#...#...#...#...#...#...#...#...
...........#...........#...#...#...#...#...#...#..
.....#...............#...##..#...#...#...#...#...#
#...#...............#...#...#...#...#...#.......#.
.#..........#.........#.......#...#...#...#.#.....
...........#...#...#...#...#...#...#......

output:

1

result:

ok single line: '1'

Test #30:

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

input:

50 50
..#...#...#...#...#...#...#...#...#...#...#...#...
...#.....#....#......#.....#...#.....#...#...#....
.#..##.......#...........##..#.....#.#......##....
#.#..##...##.#......#..#.#..#...#...#......#.....#
..#....##...#..#......#.#.....#.#.#..#..#...#...#.
......#....#..#....#..#....#...#.#.#..#...

output:

1

result:

ok single line: '1'

Test #31:

score: 0
Accepted
time: 6ms
memory: 7884kb

input:

50 50
#########################.########################
########################...#######################
#######################.....######################
######################.......#####################
#####################.........####################
####################...........########...

output:

0

result:

ok single line: '0'

Test #32:

score: 0
Accepted
time: 6ms
memory: 7716kb

input:

50 50
#########################.########################
########################...#######################
#######################.....######################
######################.......#####################
#####################.........####################
####################...........########...

output:

1

result:

ok single line: '1'

Test #33:

score: 0
Accepted
time: 6ms
memory: 9784kb

input:

50 50
...........##############.############............
...........#############...###########............
...........############.....##########............
...........###########.......#########............
...........##########.........########............
...........#########...........#######....

output:

0

result:

ok single line: '0'

Test #34:

score: 0
Accepted
time: 3ms
memory: 7904kb

input:

50 50
#########################.########################
#######..###############...#######################
######....#############.....######################
#####......###########.......#####################
####........#########.........####################
###.........########...........########...

output:

0

result:

ok single line: '0'

Test #35:

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

input:

50 50
..#...#...#...#...#...#...#...#...#...#...#...#...
.......#..##.....#.......#....##...#......#......#
.#...#...#...#.....#....#....#...#.....#.....#....
#.......#...#......#...#..#..##.......#.....#.....
......##.###........#.#....##.##..#........##....#
....##...#........#.##...##....##....#....

output:

0

result:

ok single line: '0'

Test #36:

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

input:

50 50
..#...#...#...#...#...#...#...#...#...#...#...#...
...#..##...#.....#...#.#..#...#..............#...#
.#...#...###.#.....##....#...#...#...........#....
#.#.....#...#.......##.....#.#.#.........#.....#..
.......#...#.........#....#.#.#.............#...#.
....##...#........#.....#.#....##....#....

output:

1

result:

ok single line: '1'

Test #37:

score: 0
Accepted
time: 3ms
memory: 9848kb

input:

50 50
..#...#...#...#...#...#...#...#...#...#...#...#...
...#..##...#.....#...#.#..#...#..............#...#
.#...#.#....##.....##....#...#...#...........#....
#.#.....#...#........#.....#.#.#.........#........
.......#...#........##....#.#.#.............#.....
....##...#........##....#.#....##....#....

output:

1

result:

ok single line: '1'

Test #38:

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

input:

10 10
..#...#...
.......#..
.........#
#.......#.
...#......
..........
.......#..
#.........
..#...#...
...##..#.#

output:

1

result:

ok single line: '1'

Test #39:

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

input:

47 43
#########...#...#####...#...#####...#...###
##########.....#######.....#######.....####
#########.......#####.......#####.......###
#########.......#####.......#####.......###
##########...#..######...#..######...#..###
###..#..#..#..#..#..#..#..#..#..#..#..#...#
####...#..######...#..######.....

output:

1

result:

ok single line: '1'

Subtask #2:

score: 70
Accepted

Dependency #1:

100%
Accepted

Test #40:

score: 70
Accepted
time: 90ms
memory: 59792kb

input:

983 991
#########...#...#####...#...#####...#...#####...#...#####...#...#####...#...#####...#...#####...#...#####...#...#####...#...#####...#...#####...#...#####...#...#####...#...#####...#...#####...#...#####...#...#####...#...#####...#...#####...#...#####...#...#####...#...#####...#...#####...#......

output:

1

result:

ok single line: '1'

Test #41:

score: 0
Accepted
time: 20ms
memory: 15192kb

input:

1000 1000
##################################################################################################################################################################################################################################################################################################...

output:

1

result:

ok single line: '1'

Test #42:

score: 0
Accepted
time: 24ms
memory: 15376kb

input:

1000 1000
##################################################################################################################################################################################################################################################################################################...

output:

0

result:

ok single line: '0'

Test #43:

score: 0
Accepted
time: 176ms
memory: 106900kb

input:

998 998
...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...

output:

1

result:

ok single line: '1'

Test #44:

score: 0
Accepted
time: 160ms
memory: 109208kb

input:

998 998
#..#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...

output:

0

result:

ok single line: '0'

Test #45:

score: 0
Accepted
time: 156ms
memory: 107528kb

input:

998 998
...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...

output:

1

result:

ok single line: '1'

Test #46:

score: 0
Accepted
time: 165ms
memory: 107672kb

input:

998 998
...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...#...

output:

1

result:

ok single line: '1'

Test #47:

score: 0
Accepted
time: 20ms
memory: 17868kb

input:

1000 1000
.....................................................................................................................................................................................................................................................................................................

output:

0

result:

ok single line: '0'

Test #48:

score: 0
Accepted
time: 20ms
memory: 20864kb

input:

1000 1000
.............................................................................................................................................................................#............................................................#..................#.......................................

output:

0

result:

ok single line: '0'

Test #49:

score: 0
Accepted
time: 92ms
memory: 43316kb

input:

1000 1000
.....#....#............................#...................#.###.........#.......#.#..#.......#................#.#............................#...#..............#.#........#.....#..........#.##.....#....#.......#.#...................##.........##...#.##.................#......#........#......

output:

0

result:

ok single line: '0'

Test #50:

score: 0
Accepted
time: 184ms
memory: 85580kb

input:

1000 1000
#.########......#.#....#...#..#...#.#............#..#..#.##.#.##.##...#..#...#..###....##.##.####....#....#.#.###....##.###.###...#.....#..##..##..#.#..#.###.###.#.#.....#.##........#...#.#...#.#.######.#...#.#.#..##.##.##........#.##..##...##.#####...#.####.#..#.#.##.....#....##....#.##.#...

output:

0

result:

ok single line: '0'