3.17网易笔试

今天网易笔试的第二题案例有问题吧朋友们,自己在纸上模拟下来示例也不对😥😥😥
#include<bits/stdc++.h>
using namespace std;
int m_size;
int max_st;
vector<pair<int,int>> dirs = {{1,1},{1,0},{1,-1},{0,1},{0,-1},
{-1,1},{-1,0},{-1,-1}};

void dfs(vector<string>& tmp,char a,int i,int j,int st,
vector<vector<int>>& reve,pair<int,int> dir,int step){
    int ri = i + dir.first;
    int rj = j + dir.second;
    if(ri >= 0 &&  ri < m_size && rj >= 0 && rj < m_size){
        if(tmp[ri][rj] != '-' && tmp[ri][rj] != a){
            max_st = st;      
        }
        dfs(tmp,a,ri,rj,st+1,reve,dir,step);
        if(st < max_st && tmp[ri][rj] != '-' && step - reve[ri][rj] > 1){
            if(tmp[ri][rj] == 'w') {
                tmp[ri][rj] = 'b';
                reve[ri][rj] = step;
            }
            else{
                tmp[ri][rj] = 'w';
                reve[ri][rj] = step;
            }
        }
    }
    return;
}

void operation(vector<string>& tmp,vector<vector<int>>& ope,
vector<vector<int>>& reve,int step){
    if(step > ope.size()-1) return;
    int x = ope[step][0];
    int y = ope[step][1];
    char now;
    if(step % 2 == 0) tmp[x][y] = 'w';
    else tmp[x][y] = 'b';
    for(auto dir : dirs){
        max_st = 0;
        dfs(tmp,tmp[x][y],x,y,1,reve,dir,step);      
    }

    operation(tmp,ope,reve,step+1);
}

void solution(vector<string>& tmp,vector<vector<int>>& ope){
    m_size = tmp.size();
    vector<vector<int>> reve(tmp.size(),vector<int>(tmp.size(),-2));
    operation(tmp,ope,reve,0);
    for(auto tm : tmp){
        cout<<tm<<endl;
    }
    cout<<"END"<<endl;
}


int main(){
    int T;
    cin>>T;
    while(T--){
        int n,m;
        cin>>n>>m;
        vector<string> tmp(n,"");
        vector<vector<int>> ope(m,vector<int>(2,0));
        for(int i = 0;i < n;i++){
            cin>>tmp[i];
        }
        for(int i = 0;i < m;i++){
            cin>>ope[i][0]>>ope[i][1];
        }
        solution(tmp,ope);
    }
}

#网易笔试##网易##笔经#
全部评论
测试用例有问题可能,我测试用例没过,但是题目却ac了
3 回复 分享
发布于 2022-03-17 22:39
应该是有空的间隔,夹必须是连续的
1 回复 分享
发布于 2022-03-17 22:37
没问题吧,我第二题AC了,第一题A了90%
点赞 回复 分享
发布于 2022-03-17 23:56
我是废物,一道都没做出来
点赞 回复 分享
发布于 2022-03-17 22:34
我也感觉…第二个测试样例
点赞 回复 分享
发布于 2022-03-17 22:31

相关推荐

找工作勤劳小蜜蜂:自我描述部分太差,完全看不出想从事什么行业什么岗位,也看不出想在哪个地区发展,这样 会让HR很犹豫,从而把你简历否决掉。现在企业都很注重员工稳定性和专注性,特别对于热爱本行业的员工。 你实习的工作又太传统的it开发(老旧),这部分公司已经趋于被淘汰,新兴的互联网服务业,比如物流,电商,新传媒,游戏开发和传统的It开发有天然区别。不是说传统It开发不行,而是就业岗位太少,基本趋于饱和,很多老骨头还能坚持,不需要新血液。 工作区域(比如长三角,珠三角,成渝)等也是HR考虑的因素之一,也是要你有个坚定的决心。否则去几天,人跑了,HR会被用人单位骂死。
点赞 评论 收藏
分享
牛客62533758...:华为不卡双非,而是卡院校hhhh
点赞 评论 收藏
分享
评论
1
4
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务