网易互娱在线编程纪要

第一题

public class Main {private static class Team implements Comparable<Team>{String name;int score, pureGoal, totalGoals;public Team(String name) {this.name = name;}@Overridepublic int compareTo(Team t) {return -(score != t.score ? score - t.score : pureGoal != t.pureGoal ? pureGoal - t.pureGoal : totalGoals != t.totalGoals ? totalGoals - t.totalGoals : -name.compareTo(t.name));}@Overridepublic String toString() {return name;}}   public static void main(String[] args) throws IOException {Read.init(System.in);String t1, t2;Map<String, Team> map = new HashMap<>();for (int k=0; k<4; k++) {map.clear();for (int i=0; i<6; i++) {t1 = Read.next();String temp = Read.next();t2 = Read.next();int v1 = temp.charAt(0) - '0', v2 = temp.charAt(2) - '0';int s1, s2;if (v1 > v2) {s1 = 3;s2 = 0;} else if (v1 < v2) {s1 = 0;s2 = 3;} else {s1 = s2 = 1;}if (!map.containsKey(t1)) {Team t = new Team(t1);t.score = s1;t.pureGoal = v1 - v2;t.totalGoals = v1;map.put(t1, t);} else {map.get(t1).score += s1;map.get(t1).pureGoal += (v1 - v2);map.get(t1).totalGoals += v1;}if (!map.containsKey(t2)) {Team t = new Team(t2);t.score = s2;t.pureGoal = v2 - v1;t.totalGoals = v2;map.put(t2, t);} else {map.get(t2).score += s2;map.get(t2).pureGoal += (v2 - v1);map.get(t2).totalGoals += v2;}               }List<Team> list = new ArrayList<>(map.values());Collections.sort(list);for (int i=0; i<4; i++) {if (i == 0) System.out.print(list.get(i));else System.out.print(" " + list.get(i));}System.out.println();}}}

第二题

public class Main {public static void main(String[] args) throws IOException {Read.init(System.in);int M = Read.nextInt(), N = Read.nextInt();int[][] num = new int[M][N];for (int i=0; i<M; i++) {for (int j=0; j<N; j++) {String temp = Read.next();if (temp.length() == 4 && temp.charAt(1) == 'i') {if (temp.charAt(0) == '+')num[i][j] = 111;elsenum[i][j] = -111;} else num[i][j] = Integer.parseInt(temp);}}int q = Read.nextInt();int x1, x2, y1, y2;for (int i=0; i<q; i++) {x1 = Read.nextInt() - 1;y1 = Read.nextInt() - 1;x2 = Read.nextInt() - 1;y2 = Read.nextInt() - 1;System.out.println(help(num, x1, x2, y1, y2));}}private static String help(int[][] num, int x1, int x2, int y1, int y2) {int sum = 0;boolean pinf = false, ninf = false;for (int i=x1; i<=x2; i++) {for (int j=y1; j<=y2; j++) {if (num[i][j] == 111) pinf = true;else if (num[i][j] == -111) ninf = true;else sum += num[i][j];if (pinf && ninf) return "NaN";}}if (pinf) return "+inf";else if (ninf) return "-inf";else return "" + sum;}
}

第三题(未完成)

public class Main { private static class Room {boolean isFull = false;int[] val = new int[6];int empty = 6;}static int t1, t2, t3; public static void main(String[] args) throws IOException {Read.init(System.in);int N = Read.nextInt();t1 = Read.nextInt();t2 = Read.nextInt();t3 = Read.nextInt();List<Room> lr = new ArrayList<>();int[] add = new int[N];for (int i=0; i<N; i++) {add[i] = Read.nextInt();int k = Read.nextInt();List<Integer> list = new ArrayList<>();for (int j=0; j<k; j++) {list.add(Read.nextInt());}if (lr.size() == 0 || needNew(lr, list)) {Room r = new Room();r.empty = 6 - list.size();for (int j=0; j<list.size(); j++)r.val[i] = list.get(i);if (r.empty == 0) r.isFull = true;lr.add(r);} else {int pre = -1;boolean first = true;for (int j=0; j<lr.size(); j++) {if (lr.get(j).isFull) continue;if (first && lr.get(j).empty >= list.size()) {first = false;pre = j;int sum = 0, sum2 = 0;for (int k1=0; k1<6; k1++) sum += lr.get(j).val[k1];for (int k1=0; k1<list.size(); k1++) {sum += list.get(k1);sum2 += list.get(k1);}sum /= (6 - lr.get(j).empty + list.size());sum2 /= list.size();if (Math.abs(sum - sum2) < t1) {lr.get(j).empty -= list.size();for (int k1=6-lr.get(j).empty; k1<6-lr.get(j).empty+list.size(); k1++)lr.get(j).val[k1] = list.get(k1-6-lr.get(j).empty);if (lr.get(j).empty == 0) lr.get(j).isFull = true;} }}lr.get(pre).empty -= list.size();for (int k1=6-lr.get(pre).empty; k1<6-lr.get(pre).empty+list.size(); k1++)lr.get(pre).val[k1] = list.get(k1-6-lr.get(pre).empty);if (lr.get(pre).empty == 0) lr.get(pre).isFull = true;}/*未完待续*/}}   private static boolean needNew(List<Room> lr, List<Integer> list) {int i = 0;for (; i<lr.size(); i++) {if (!lr.get(i).isFull && lr.get(i).empty >= list.size()) break;}if (i == lr.size()) return true;return false;}
}

统一的读入方式

class Read {static BufferedReader br;static StringTokenizer st;static void init(InputStream in) {br = new BufferedReader(new InputStreamReader(in));st = new StringTokenizer("");}public static double nextDouble() throws IOException {return Double.parseDouble(next());}static String next() throws IOException {while (!st.hasMoreTokens()) {st = new StringTokenizer(br.readLine());}return st.nextToken();}static int nextInt() throws IOException {return Integer.parseInt(next());}
}

C版本的第二题

#include <stdio.h>
#include <string>
#include <iostream>
using namespace std;
int M, N;
int a[1005][1005];
void help(int x1, int x2, int y1, int y2) {int sum = 0;bool b1 = false, b2 = false;for (int i=x1; i<=x2; i++) {for (int j=y1; j<=y2; j++) {if (a[i][j] == 111) b1 = true;else if (a[i][j] == -111) b2 = true;else sum += a[i][j];if (b1 && b2) {printf("NaN\n"); return;}}}if (b1) printf("+inf");else if (b2) printf("-inf");else printf("%d", sum);printf("\n");
}
int main() {    scanf("%d%d", &M, &N);string s;for (int i=0; i<M; i++) {for (int j=0; j<N; j++) {cin >> s;if (s.length() == 4 && s[1] == 'i') {if (s[0] == '+') a[i][j] = 111;else a[i][j] = -111;} else a[i][j] = stoi(s);}}int q;scanf("%d", &q);int x1, y1, x2, y2;for (int i=0; i<q; i++) {cin >> x1 >> y1 >> x2 >> y2;help(x1-1, x2-1, y1-1, y2-1);}return 0;
}

总结

  • 浪费时间想在时间上AC第二题,于是写了个C版本,但还是没通过,结果浪费了大量时间,导致第三题没写完;
  • 大概也就一周没刷题,感觉思路就没那么便捷了,看来还是自己太菜;
  • 第三道题思路不难,主要是很复杂,得细细捋一遍,等有时间再补上完整代码;

网易互娱在线编程纪要相关推荐

  1. 网易互娱2018校招游戏研发工程师在线笔试

    如果题目版权限制,不能发表该题解,请私信,我会立刻删除博客. 题目描述 注意:本题只允许使用C/C++或Java进行解答,其他编程语言提交均视作无效处理. 小W有一个电子时钟用于显示时间,显示的格式为 ...

  2. 【面试题】网易互娱(游戏)2021校园招聘在线笔试 - 服务端开发工程师[螺旋矩阵]

    昨晚做网易互娱的笔试,比较尴尬的是只能用C/C++/Java,而本人对C/C++的了解仅限于大一的课程设计(而且一年多没用过C写代码了),Java差不多看得懂代码但是没有系统的学过.无奈最后只能用py ...

  3. 【面试题】网易互娱(游戏)2021校园招聘在线笔试 - 服务端开发工程师[文件系统]

    昨晚做网易互娱的笔试,比较尴尬的是只能用C/C++/Java,而本人对C/C++的了解仅限于大一的课程设计(而且一年多没用过C写代码了),Java差不多看得懂代码但是没有系统的学过.无奈最后只能用py ...

  4. 网易互娱C++岗一面面经(凉面)

    前言 我报的网易互娱的提前批游戏研发工程师C++岗,这个过程其实挺坎坷的,8月初跟着导师去黑龙江佳木斯开会,中途忽然间接到通知要笔试,从会场逃出来在宾馆做的远程笔试题,做的不是特别好,4道题只做对了一 ...

  5. 橙汁的面试经验汇总(百度、平安壹钱包、诺瓦、快手、bigo、海信、奇安信、小米、迈瑞医疗、顺丰、网易互娱、多益游戏、京东、穆迪)

    百度 二面 1.首先1到2分钟进行一个自我介绍 2.然后介绍一下你最拿手的项目 3.介绍完项目之后,因为涉及到数据库和监控问道如下问题 4.为什么选择zabbix 5.如果你的项目商用,你觉得哪里还可 ...

  6. 【2020校招总结】接受社会的毒打,收获腾讯天美、字节跳动、网易互娱、华为等offer(开发岗)

    文章目录 0.背景介绍 1.时间节点 2.关于暑期实习 3.关于刷题及看书学习 4.关于测评 5.关于笔试 6.关于面试 7.关于岗位选择 0.背景介绍 回忆起下决心转行,已经快一年的时间了,当然,如 ...

  7. 4.11日网易互娱笔试

    参考: 4.11网易互娱服务端java笔试 2020/4/11 网易游戏后台开发笔试,4道编程题 4.11 网易互娱2020届校招补录笔试-服务端笔经 网易互娱笔试 类似的题目 2. 两数相加 415 ...

  8. 杭州内推 | 网易互娱AI Lab招聘NLP/数据挖掘/图像算法实习生

    合适的工作难找?最新的招聘信息也不知道? AI 求职为大家精选人工智能领域最新鲜的招聘信息,助你先人一步投递,快人一步入职! 网易互娱AI Lab 网易互娱AI Lab成立于2017年,是专注于游戏领 ...

  9. 腾讯游戏客户端开发网易互娱暑期实习面经

    腾讯提前批(二面挂) 在打算笔试的下午,收到了一面电话通知,周一去腾讯上海大厦现场面试,于是提前批的笔试就没有参加(这可能有点影响) 腾讯一面 和面试官约了时间,结果到了腾讯大厦楼下没法进去,所以只能 ...

最新文章

  1. python模拟按键_python 模拟按键放在模拟器Python初学者的17个技巧
  2. 玲珑杯 1157 - 造物主的戒律 主席树+离散化
  3. C++ Primer 有感(类)
  4. 爬虫学习--豆瓣top250
  5. Web框架——Flask系列之设置和读取cookie(十五)
  6. 绿得发娇的企业即时通讯软件
  7. Hadoop数据压缩 与 数据清洗ETL
  8. 逻辑回归(LR)个人学习总结篇
  9. Head First Design Pattern 读书笔记(4) 工厂模式
  10. Eclipse+Wildfly10 创建第一个EJB项目
  11. 计算机主机爆炸,意外:插入计算机后,主机的电源就会烧断。发生了什么?计算机电源爆炸了吗?...
  12. CF-C. Dima and Salad
  13. 软件类大学生求职就业攻略(四)——求职面试
  14. Kubernetes实战[2]: 服务发现机制与Cluster DNS的安装(无CA认证版)
  15. 什么是FBO (Frame Buffer Object)
  16. 西门子300 PLC 功能块及背景数据块的说明
  17. Python AutoCAD 注释
  18. python数据分析六个环节_安利6个珍藏的Python数据分析神器
  19. [BUU刷题记录]day01-起步
  20. v4l2及gstreamer使用指南

热门文章

  1. python函数教程:len()方法
  2. 2022第四届中国(山东)国际大健康产业博览会,即将开幕
  3. 【踩坑】python: This install of SoX cannot process .mp3 files
  4. 序列标注NER、POS、Chunking、SRL
  5. sinc函数卷积_从采样点到声音:sinc函数和卷积
  6. word标题和文字直接的空格
  7. iOS模拟器运行报错Unable to install /xxx/build/ios/iphonesimulator/Runner.app
  8. 活体检测-用照片来做人脸识别可行吗?
  9. 拒绝男程序员?程序员就活该接盘?
  10. 不需要下载7-zip 解压 7z.001 7z.002 7z.003