3.26 网易雷火笔试统计

1.统计。(简单遍历)
2.计算N张卡的得分。(模拟)
3.句子按行输出。(模拟,怎么感觉样例有问题,只过了48%。。)
4.海水上涨,到达目标岛屿至少等待时间。(bfs+优先队列,https://leetcode-cn.com/problems/swim-in-rising-water/

----------------------------------------------

17:20更新

第一题 直接统计

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

int a[101][101];

int main() {

    int n, m;
    cin >> n >> m;
    int x, y;
    cin >> x >> y;
    int ans = 0;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            cin >> a[i][j];
            if(i == x - 1 && j == y - 1) continue;
            ans += a[i][j];
        }
    }
    cout << ans + 1 << endl;
    

    return 0;
}

第二题 模拟
#include <bits/stdc++.h>
using namespace std;


int main() {

    int M;
    cin >> M;
    while(M--) {
        int N;
        cin >> N;
        vector<int>a(N);
        for(int i = 0; i < N; i++) {
            cin >> a[i];
        }
        vector<char>b(N);
        for(int i = 0; i < N; i++) {
            cin >> b[i];
        }
        if(N == 5) {
            bool flag = true;
            for(int i = 0; i < N; i++) if(a[i] != a[0]) {
                flag = false;
                break;
            }
            if(flag) {
                cout << 15000 << endl;
                continue;
            }
            
            flag = true;
            for(int i = 0; i < N; i++) if(b[i] != b[0]) {
                flag = false;
                break;
            }
            if(flag) {//lei bie xiang tong
                sort(a.begin(), a.end());
                for(int i = 1; i < N; i++) if(a[i] != a[i - 1] + 1) {
                    flag = false;
                    break;
                }
                if(flag) {
                    cout << 8000 << endl;
                    continue;
                } else {
                    cout << 300 << endl;
                    continue;
                }
            }
        }
        unordered_map<int, int>mp;
        for(int i = 0; i < N; i++) mp[a[i]]++;
        int count1 = 0, count2 = 0, count3 = 0, count4 = 0, count5;
        for(auto &[k, v]: mp) {
            if(v == 5) {
                count5++;
            } else if(v == 4) {
                count4++;
            } else if(v == 3) {
                count3++;
            } else if(v == 2) {
                count2++;
            } else if(v == 1) {
                count1++;
            }
        }
        if(count4) {
            cout << 150 << endl;
            continue;
        }
        if(count3 && count2) {
            cout << 40 << endl;
            continue;
        }
        if(N == 5) {
            sort(a.begin(), a.end());
            bool flag = true;
            for(int i = 1; i < N; i++) if(a[i] != a[i - 1] + 1) {
                flag = false;
                break;
            } 
            if(flag) {
                cout << 20 << endl;
                continue;
            }
        }
        if(count3) {
            cout << 6 << endl;
            continue;
        }
        if(count2 == 2) {
            cout << 4 << endl;
            continue;
        }
        if(count2 == 1) {
            cout << 2 << endl;
            continue;
        }
        cout << 1 << endl;
    }
    
    

    return 0;
}


第三题 模拟,怎么感觉样例有问题,只过了48%。。
#include <bits/stdc++.h>
using namespace std;


int main() {

    int n, m;
    cin >> n >> m;
    getchar();
    string s;
    getline(cin, s);
    vector<string>words;
    string word;
    stringstream ss(s);
    while(getline(ss, word, ' ')) {
        if(!word.empty()) {
            words.push_back(word);
        }
    }
    vector<string>ans;
    s = "";
    for(int i = 0; i < words.size(); i++) {
        if(s.empty()) {
            s = words[i];
            continue;
        }
        int next_len = 0;
        if(isalpha(words[i].back())) {
            next_len = s.size() + 1 + words[i].size();
        } else {
            next_len = s.size() + words[i].size();
        }
        if(next_len > n) {
            if(next_len <= n + m) {
                s.append(" " + words[i]);
                ans.push_back(s);
                s = "";
            } else {
                ans.push_back(s);
                s = words[i];
            }
        } else {
            s.append(" " + words[i]);
        }
    }
    if(!s.empty()) ans.push_back(s);
    cout << ans.size() << endl;
    for(auto &i: ans) cout << i << endl;
    
    return 0;
}



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

int dir[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
int a[701][701];
bool vis[701][701];

struct Node {
    int x, y, hour;
    Node(int i, int j, int k): x(i), y(j), hour(k) {}
    bool operator<(const Node &p) const {
        return hour > p.hour;
    }
};

int main() {
    
    memset(vis, 0, sizeof(vis));
    int n, m, x, y, z, w;
    cin >> n >> m >> x >> y >> z >> w;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    --x, --y, --z, --w;
    int nowH = 0;
    priority_queue<Node>q;
    q.emplace(Node(x, y, a[x][y]));//注意如果在原点,也要等到海面涨到该高度时才能运走!!
    int ans = 0;
    vis[x][y] = true;
    while(!q.empty()) {
        auto now = q.top();
        q.pop();
        if(now.x == z && now.y == w) {
            ans = now.hour;
            break;
        }
        for(int i = 0; i < 4; i++) {
            int next_x = now.x + dir[i][0];
            int next_y = now.y + dir[i][1];
            if(next_x >= 0 && next_x < n && next_y >= 0 && next_y < m && !vis[next_x][next_y]) {
                if(now.hour >= a[next_x][next_y]) {//当前时间下,水面早已经涨到这个高度了
                    q.emplace(Node(next_x, next_y, now.hour));
                } else {//否则至少要等到a[next_x][next_y]时水面才能涨到该位置
                    q.emplace(Node(next_x, next_y, a[next_x][next_y]));
                }
                vis[next_x][next_y] = true;
            }
        }
    }
    cout << ans << endl;

    return 0;
}



#网易实习##网易雷火##笔试题目#
全部评论
好多人全对啊,这个东西已经卷成这样了吗🤕
18 回复 分享
发布于 2022-03-26 16:15
我估计有很多路过的投了全对🤣
10 回复 分享
发布于 2022-03-26 16:27
一个半小时a了3.8,有事直接退了,无ak😔
2 回复 分享
发布于 2022-03-26 19:56
现在全对的还挺多,放个题解https://m.nowcoder.com/discuss/899991?&headNav=www
2 回复 分享
发布于 2022-03-26 17:18
有大佬第三题样例报错,但是检测不出差别的吗?🤣🤣🤣🤣
2 回复 分享
发布于 2022-03-26 17:07
第二题过1.67什么鬼啊,第三题嗯是不会输入一句英文,麻了。
2 回复 分享
发布于 2022-03-26 16:58
第三题愣是不会😕
2 回复 分享
发布于 2022-03-26 16:40
第三题85。不知道哪里没过😂
1 回复 分享
发布于 2022-03-26 17:02
这题,想笑😅
点赞 回复 分享
发布于 2022-03-26 16:52
有没有好兄弟已经收到面试邀请了,俺的状态还在笔试中,互娱倒是第二天就出结果了
点赞 回复 分享
发布于 2022-03-29 14:04
【华为实习生招聘】云核心网产品线 【部门简介】 泛在网络,智能核心—核心网产品线 云核心网是5G数字世界的控制核心,核心业务全球持续领先,5G合同数持续领先! 我们聚焦于5G网络、AllCloud、数据处理、云计算、音视频、边缘计算、网络自动驾驶等领域,融合“联接+云+计算”能力,为全球客户提供差异化服务,使能千行百业向数字化转型,构建万物互联的数字世界。 少年云核朝气蓬勃、充满希望,奔跑吧!少年云核,我们期待你的加入! https://mp.weixin.qq.com/s/danZe0p_zF7n-eBZnjgKjg 【我们的优势】 这里有50+前沿技术课题等你来探索来挑战,这里有28大技术领域方向任你选择;这里有大牛带队,专属双导师制;这里技术氛围浓厚,可以结识优秀队友;这里理论结合实践,祝你飞速成长,这里多重福利等你来解锁^_^ https://mp.weixin.qq.com/s/51Bodg3Khh7yOQbUvPTn2w 【招聘岗位】 ✔️软件开发类 通用软件开发工程师 ✔ 大牛带队,专属双导师制 ✔️ 地点:东莞,西安 欢迎聊聊,给你匹配合适工作。 https://mp.weixin.qq.com/s/EwA955Fxr0RXPbKF5laOBg 【面向人群】 2023年1月1日—2023年12月31日期间毕业的国内本硕 【招聘流程】 1.投递、筛选 2.机考(三道编程题,可在牛客网练习题库训练) 3.综合测试 4.1轮技术面试(有手撕代码环节) 5.1轮主管面试 6.审批发offer 【联系方式】欢迎踊跃投递;详细信息可私聊咨询;**************************************
点赞 回复 分享
发布于 2022-03-29 13:49
一般是不是笔试没做完就没面试机会了
点赞 回复 分享
发布于 2022-03-29 12:47
你们都是后端或者是开发吗?我投递的“测试”,为什么没有收到面试通知?
点赞 回复 分享
发布于 2022-03-27 11:23
100 16.7 88 78 我还有机会吗,第二题心态都崩了
点赞 回复 分享
发布于 2022-03-26 18:37
100 100 85 0 还有面试机会么
点赞 回复 分享
发布于 2022-03-26 18:05
t3得了98😤
点赞 回复 分享
发布于 2022-03-26 17:26
96.67心态崩了
点赞 回复 分享
发布于 2022-03-26 17:17
100 100 100 92 第一题送分题 第二题枚举所有情况 第三题LC魔改题,原有基础加上m的范围量 第四题LC原题,并查集
点赞 回复 分享
发布于 2022-03-26 17:15
第二题我把几张牌也考虑了,2、3、4、5自己测试半天,也没找到出错的啊,为啥总是1.67%😥
点赞 回复 分享
发布于 2022-03-26 17:11
100 97 100 2 第四题二分+广搜 A* 都试了,不是超时就是超内存,难道我被卡cin了
点赞 回复 分享
发布于 2022-03-26 17:11

相关推荐

评论
12
44
分享

创作者周榜

更多
牛客网
牛客企业服务