2^6分,大佬救救

P1162 填涂颜色

hanwud @ 2024-03-30 09:00:15


#include<bits/stdc++.h>
using namespace std;
int n,a[31][31];
bool visit=false;
int main(){
    cin>>n;
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++){
            cin>>a[i][j];
    } 
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(a[i][j] == 0 && visit) a[i][j] = 2;
            if(a[i][j] == 1)   visit=true;
        }
        visit=false;
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cout<<a[i][j]<<" ";
        }
        cout<<endl;
    }   
    return 0;
}

by Lazy_make_name @ 2024-03-30 12:11:48

visit=true

应改为

visit=!visit

by c_subtract_subtract @ 2024-04-22 20:45:03

本人好心帮你看了下测试点 输入: 0 0 1 1 1 0 1 1 1 0 1 0 1 0 0 0 0 1 1 1 0 1 1 1 0 1 0 1 0 0 0 1 1 1 0 0 输出: 0 0 1 1 1 2 1 1 1 2 1 0 1 2 2 2 2 1 1 1 0 1 1 1 0 1 2 1 0 0 0 1 1 1 2 2 懂得都懂是什么问题


by c_subtract_subtract @ 2024-04-22 21:04:05

逻辑全错啦,大哥!bfs啊!!!!


|