网易互娱游戏研发工程师笔试

刚刚发错区了2333

做了3.3题,最后一题Trie没调出来只交了30%的简单map匹配(我这个菜鸡 =-=话说第三题真的看的脑袋疼,做完第三题整个人差不多就虚脱了 =-=),以下是前三题AC。
因为vi并没有好好配置 =-= 所以这里面缩进非常恶心 =-= 请不要打我
第一题(暴力,完全有更好的写法)(以及其实最后的判断有点傻):
#include <bits/stdc++.h>

using namespace std;

int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; ++i) {
    int num;
    cin >> num;
    num -= 5000;
    double res = 0;
    if (num > 80000) {
      res += 0.45 * (num - 80000);
    }
    if (num > 55000) {
      res += 0.35 * (((num > 80000) ? 80000 : num) - 55000);
    }
    if (num > 35000) {
      res += 0.30 * (((num > 55000) ? 55000 : num) - 35000);
    }
    if (num > 25000) {
      res += 0.25 * (((num > 35000) ? 35000 : num) - 25000);
    }
    if (num > 12000) {
      res += 0.20 * (((num > 25000) ? 25000 : num) - 12000);
    }
    if (num > 3000) {
      res += 0.10 * (((num > 12000) ? 12000 : num) - 3000);
    }
    if (num >= 0) {
      res += 0.03 * (((num > 3000) ? 3000 : num) - 0);
    }
    cout << ((res - floor(res) >= 0.5) ? ceil(res) : floor(res)) << endl;
  } 
  return 0;
}

第二题(暴力 =-=):

#include <bits/stdc++.h>

using namespace std;

const string commons[6] = {"password", "admin", "qwerty", "hello", "iloveyou", "112233"};
const int COMMONNUM = 6;
string specials = "!@#$%^&*()_-=+[]{},.<>/?";
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    // cout << s << endl;
    if (s.size() < 8) {
      cout << "no" << endl;
    } else {
      bool containCommon = false;
      for (int i = 0; i < COMMONNUM; ++i) {
        for (int j = 0; j < s.size() - commons[i].size() + 1; ++j) {
      // string tmp = s.substr(j, commons[i].size());
      // cout << commons[i] << endl;
          if (s.substr(j, commons[i].size()) == commons[i]) {
        containCommon = true;
        break;
      }
    }
    if (containCommon) break;
      }
      if (containCommon) {
        cout << "no" << endl;
      } else {
        bool lastIsNum = false, lastIsUpper = false, lastIsLower = false;
        bool hasNum = false, hasLower = false, hasUpper = false, hasSpec = false;
        int conNum = 0, conUpper = 0, conLower = 0;

    bool noPass = false;
        for (int i = 0; i < s.size(); ++i) {
          char c = s[i];
      if (specials.find(c) != string::npos) {
        hasSpec = true;
      } else {
        if (c >= '0' && c <= '9') {
          hasNum = true;
          conUpper = 0;
          conLower = 0;
          if (lastIsNum) conNum++;
          else conNum = 1;
          if (conNum >= 3) {
            if (s[i] - s[i - 1] == s[i - 1] - s[i - 2]) {
              noPass = true;
          break;
        } else {
          conNum--;
        }
          }
          lastIsNum = true;
          lastIsUpper = false;
          lastIsLower = false;
        } else if (c >= 'a' && c <= 'z') {
          hasLower = true;
          conUpper = 0;
          conNum = 0;
          if (lastIsLower) conLower++;
          else conLower = 1;
          if (conLower >= 3) {
            if (s[i] - s[i - 1] == 1 && s[i - 1] - s[i - 2] == 1) {
              noPass = true;
          break;
        } else {
              conLower--;
        }
          }
          lastIsLower = true;
          lastIsUpper = false;
          lastIsNum = false;
        } else {
          hasUpper = true;
          conLower = 0;
          conNum = 0;
          if (lastIsUpper) conUpper++;
          else conUpper = 1;
          if (conUpper >= 3) {
            if (s[i] - s[i - 1] == 1 && s[i - 1] - s[i - 2] == 1) {
              noPass = true;
          break;
        } else {
              conUpper--;
        }
          }
          lastIsUpper = true;
          lastIsLower = false;
          lastIsNum = false;
        }
      }
        }
    if (!hasNum || !hasLower || !hasUpper || !hasSpec) {
      noPass = true;
    }
    if (noPass) {
      cout << "no" << endl;
    } else {
      cout << "yes" << endl;
    }
      }
    }
  }
  return 0;
}

第三题(暴力模拟):

#include <bits/stdc++.h>

using namespace std;

int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; ++i) {
    int q, n, m;
    cin >> q >> n >> m;
    unordered_map<int, int> rankscore;
    for (int i = 0; i < n; ++i) {
      int left, right, score;
      cin >> left >> right >> score;
      for (int j = left; j <= right; ++j) {
        rankscore[j] = score;
      }
    }

    unordered_map<int, int> killscore;
    for (int i = 0; i <= m; ++i) {
      int score;
      cin >> score;
      killscore[i] = score;
    }

    int a, b;
    cin >> a >> b;

    map<string, int> totalscore;

    unordered_map<string, int> killnum;
    unordered_map<string, int> livetime;
    vector<string> rank;
    for (int i = 0; i < q - 1; ++i) {
      int time;
      string killer, victim;
      cin >> time >> killer >> victim;
      // cout << time << killer << victim << endl;
      rank.push_back(victim);
      if (i == q - 2) rank.push_back(killer);
      livetime[victim] = time;
      if (i == q - 2) livetime[killer] = time;
      if (killer != victim) {
        killnum[killer]++;
    if (killnum[victim] >= m) {
          totalscore[killer] += killscore[m];
    } else {
          totalscore[killer] += killscore[killnum[victim]];
    }
      }
    }

    reverse(rank.begin(), rank.end());

    for (int i = 0; i < rank.size(); ++i) {
      string now = rank[i];
      // cout << now << " : " << endl;
      totalscore[now] += rankscore[i + 1];
      // cout << totalscore[now] << endl;
      totalscore[now] += livetime[now] * a + b;
      // cout << totalscore[now] << endl;
    }

    for (auto it : totalscore) {
      cout << it.first << " " << it.second << endl;
    }
  }
  return 0;
}

第四题就不发了 =-= 我反正也没AC =-=
祝大家好运!

#网易##笔试题目#
全部评论
网易还有全暴力的题目
点赞 回复 分享
发布于 2018-08-09 22:38
这里a了3题,第3题没ac,就因为漏算了吃鸡的分… 要不就满分了QAQ
点赞 回复 分享
发布于 2018-08-09 22:41

相关推荐

霁华Tel:秋招结束了,好累。我自编了一篇对话,语言别人看不懂,我觉得有某种力量在控制我的身体,我明明觉得有些东西就在眼前,但身边的人却说啥也没有,有神秘人通过电视,手机等在暗暗的给我发信号,我有时候会突然觉得身体的某一部分不属于我了。面对不同的人或场合,我表现出不一样的自己,以至于都不知道自己到底是什么样子的人。我觉得我已经做的很好,不需要其他人的建议和批评,我有些时候难以控制的兴奋,但是呼吸都让人开心。
点赞 评论 收藏
分享
Java抽象带篮子:难蚌,点进图片上面就是我的大头😆
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务