QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#338218#4079. 칠하기hotboy27030 4ms16120kbC++204.0kb2024-02-25 19:16:222024-02-25 19:16:23

Judging History

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

  • [2024-02-25 19:16:23]
  • 评测
  • 测评结果:0
  • 用时:4ms
  • 内存:16120kb
  • [2024-02-25 19:16:22]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define pll pair <ll,ll>
#define fi first
#define se second
#define sz(a) (ll((a).size()))
#define BIT(mask,i) (((mask) >> (i))&1LL)
#define MASK(i) (1LL << (i))
#define MP make_pair
ll ptr=0;
const ll MAXN=1000;
ll row[MAXN+100][MAXN+100],col[MAXN+100][MAXN+100];
ll timeDFS;
stack <ll> s;
ll sz_comp;
ll in[MAXN*MAXN+100],out[MAXN*MAXN+100],low[MAXN*MAXN+100],comp[MAXN*MAXN+100];
bool deleted[MAXN*MAXN+100];
ll comp_out[MAXN*MAXN+100];
vector <ll> g[MAXN*MAXN+100];
vector <ll> comp_g[MAXN*MAXN+100];
ll order_comp[MAXN*MAXN+100];
void dfs(ll u){
    in[u] = low[u] = ++timeDFS;
    s.push(u);
    for (auto v:g[u]){
        if (!in[v]){
            dfs(v);
            low[u] = min(low[u],low[v]);
        }
        else{
            if (!deleted[v])low[u] = min(low[u],in[v]);
        }
    }
    out[u] = timeDFS;
    if (low[u]==in[u]){
        sz_comp++;
        while (s.top()!=u){
            comp[s.top()]=sz_comp;
            deleted[s.top()]=1;
            s.pop();
        }
        comp[s.top()]=sz_comp;
        deleted[s.top()]=1;
        s.pop();
    }

}
int yellowblue(int n, int m, std::vector<std::string> s)
{
    for (ll i = 0;i < n;i ++){
        ll last = -1;
        for (ll j = 0;j <= m;j ++){
            if (j == m || s[i][j]=='#' ){
                if (j-last>1){
                    ll tmp=++ptr;
                    for (ll k = last+1;k < j;k ++){
                        row[i][k] = tmp;
                    }
                }
                last=j;
            }
        }
    }
    for (ll j = 0;j < m;j ++){
        ll last = -1;
        for (ll i = 0;i <= n;i ++){
            if (i==n||s[i][j]=='#'){
                if (i-last>1){
                    ll tmp =++ptr;
                    for (ll k = last+1;k < i;k ++){
                        col[k][j] = tmp;
                    }
                }
                last=i;
            }
        }
    }
    for (ll i = 0;i < n;i ++){
        ll last = -1;
        for (ll j = 0;j <= m;j ++){
            if (j == m || s[i][j]=='#'){
                if (j-last>1){
                    g[row[i][last+1]].push_back(col[i][last+1]);
                    g[row[i][j-1]].push_back(col[i][j-1]);
                }
                last=j;
            }
        }
    }
    for (ll j = 0;j < m;j ++){
        ll last = -1;
        for (ll i = 0;i <= n;i ++){
            if (i==n||s[i][j]=='#'){
                if (i-last>1){
                    g[col[last+1][j]].push_back(row[last+1][j]);
                    g[col[i-1][j]].push_back(row[i-1][j]);
                }
                last=i;
            }
        }
    }
//    for (ll i = 0;i < n;i ++){
//        for (ll j = 0;j < m;j ++){
//            cout<<row[i][j];
//        }
//        cout<<'\n';
//    }
//    cout<<'\n';
//    for (ll i = 0;i < n;i ++){
//        for (ll j = 0;j < m;j ++){
//            cout<<col[i][j];
//        }
//        cout<<'\n';
//    }
//    cout<<'\n';
//    for (ll i = 1;i <= ptr;i ++){
//        for (auto v:g[i]){
//            cout<<i<<' '<<v<<endl;
//        }
//    }
    for (ll i = 1;i <= ptr;i ++)if (!in[i])dfs(i);
//    for (ll i = 1;i <= ptr;i ++)cout<<i<<' '<<in[i]<<' '<<low[i]<<endl;
//    for (ll i = 1;i <= ptr;i ++)cout<<comp[i]<<' ';
//    cout<<endl;
    for (ll i = 1;i <= ptr;i ++){
        comp_out[comp[i]] = max(comp_out[comp[i]],out[i]);
        for (auto v:g[i]){
            comp_g[comp[i]].push_back(comp[v]);
        }
    }
    iota(order_comp+1,order_comp+1+sz_comp,1);
    sort(order_comp+1,order_comp+1+sz_comp,[&](ll x,ll y){return comp_out[x]>comp_out[y];});
    bool ok = 1;
    for (ll i = 1;i + 1 <= sz_comp;i ++){
        bool fail = 1;
        for (auto v:comp_g[order_comp[i]]){
            if (v==order_comp[i+1])fail = 0;
        }
        if (fail)ok=0;
    }
	return ok;
//return 1;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 30
Accepted
time: 4ms
memory: 13840kb

input:

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

output:

1

result:

ok single line: '1'

Test #2:

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

input:

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

output:

1

result:

ok single line: '1'

Test #3:

score: 0
Accepted
time: 4ms
memory: 13856kb

input:

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

output:

1

result:

ok single line: '1'

Test #4:

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

input:

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

output:

0

result:

ok single line: '0'

Test #5:

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

input:

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

output:

1

result:

ok single line: '1'

Test #6:

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

input:

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

output:

1

result:

ok single line: '1'

Test #7:

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

input:

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

output:

1

result:

ok single line: '1'

Test #8:

score: 0
Accepted
time: 4ms
memory: 13872kb

input:

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

output:

0

result:

ok single line: '0'

Test #9:

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

input:

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

output:

1

result:

ok single line: '1'

Test #10:

score: 0
Accepted
time: 4ms
memory: 14000kb

input:

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

output:

0

result:

ok single line: '0'

Test #11:

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

input:

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

output:

0

result:

ok single line: '0'

Test #12:

score: 0
Accepted
time: 4ms
memory: 11808kb

input:

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

output:

0

result:

ok single line: '0'

Test #13:

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

input:

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

output:

0

result:

ok single line: '0'

Test #14:

score: 0
Accepted
time: 4ms
memory: 14088kb

input:

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

output:

0

result:

ok single line: '0'

Test #15:

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

input:

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

output:

0

result:

ok single line: '0'

Test #16:

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

input:

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

output:

0

result:

ok single line: '0'

Test #17:

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

input:

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

output:

0

result:

ok single line: '0'

Test #18:

score: 0
Accepted
time: 4ms
memory: 14124kb

input:

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

output:

0

result:

ok single line: '0'

Test #19:

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

input:

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

output:

0

result:

ok single line: '0'

Test #20:

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

input:

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

output:

0

result:

ok single line: '0'

Test #21:

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

input:

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

output:

0

result:

ok single line: '0'

Test #22:

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

input:

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

output:

0

result:

ok single line: '0'

Test #23:

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

input:

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

output:

0

result:

ok single line: '0'

Test #24:

score: 0
Accepted
time: 4ms
memory: 16120kb

input:

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

output:

0

result:

ok single line: '0'

Test #25:

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

input:

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

output:

1

result:

ok single line: '1'

Test #26:

score: -30
Wrong Answer
time: 4ms
memory: 14048kb

input:

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

output:

0

result:

wrong answer 1st lines differ - expected: '1', found: '0'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%