网易笔试

求第一题那个10*10数组
代码或者题目都行
没过想回顾一下
#网易#
全部评论
测试用例         2                              // 2 组         10 3                           // 10 x 10 大小,刀长 3         0 0 0 0 0 0 0 0 0 0         0 0 0 0 0 0 0 0 0 0         0 0 0 0 0 0 0 0 0 0         0 0 0 0 0 0 0 0 0 0         0 0 0 0 2 0 0 0 0 0         0 0 0 0 0 0 0 0 0 0         0 0 0 0 1 0 2 0 0 0         0 0 0 0 0 0 0 0 0 2         0 0 0 1 0 0 0 0 0 1         0 0 0 1 0 0 2 0 2 0         8 8                            // 起始位置 (8,8)         10 2                           // 10 x 10 大小,刀长 2         0 0 0 0 0 0 0 0 0 0         0 0 0 0 0 0 0 0 0 0         0 0 0 0 0 0 0 0 0 0         0 0 0 0 0 0 0 0 0 0         0 0 2 0 0 1 0 0 0 0         0 0 0 1 2 0 2 0 0 0         0 0 0 0 2 1 2 0 2 0         0 0 2 0 0 0 0 0 2 0         0 0 0 0 0 0 0 2 0 0         0 0 0 1 0 0 0 0 0 0         2 5                             // 起始位置 (2,5)
点赞 回复 分享
发布于 2020-04-11 22:21
现在把自己改来改去的代码放出来吧,反正与网易无缘了,测试用例也全靠回忆,要是有大佬来看出错误欢迎指正。
点赞 回复 分享
发布于 2020-04-11 22:13
for (j = 0; j < M; j++) { for (int m = 0; m < M; m++) { if (b[j][m] != 0) { cout << "b[j][m]" << b[j][m] << " " << "j" << j << " " << m << endl; double q = (x - j)*(x - j) + (y - m)*(y - m); cout << "q" << q << endl; e[i] = q; if (mp[e[i]] != 0)mp[e[i]] += b[j][m]; else mp[q] = b[j][m]; i++; } } } for (j = 0; j < i; j++)cout << e[j]<<endl; sort(e, e + i); for (j = 0; j < i; j++)cout << e[j] <<" "<<mp[e[j]]<<endl; j = 0; while(mp[e[j]]<=L&&j<i){ if (e[j + 1] == e[j]) j++; L = L + mp[e[j]]; j++; cout << "L" << L<<"i"<<i<<" "<<j<<endl; } cout << L << endl; } return 0; }
点赞 回复 分享
发布于 2020-04-11 22:12
#include<iostream> #include<vector> #include<math.h> #include<algorithm> #include<map> int b[500][500]; double e[500]; using namespace std; int main() { int T; cin >> T; int i; int j; for (i = 0; i < T; i++) { int M; int L; cin >> M; cin >> L; for (j = 0; j < M; j++) { for (int m = 0; m < M; m++) { cin >> b[j][m]; } } int x; int y; cin >> x; cin >> y; i = 0; map<double, int> mp;
点赞 回复 分享
发布于 2020-04-11 22:12
代码比较丑,但这是我过的唯一一道了T_T
点赞 回复 分享
发布于 2020-04-11 21:48
int main(int argc, char const *argv[]) {     int T;     cin >> T;     for (int i = 0; i < T; ++i)     {         int M, L;         cin >> M >> L;         vector<vector<int>> place(M, vector<int>(M, 0));         for (int j = 0; j < M; ++j)         {             for (int k = 0; k < M; ++k)             {                 cin >> place[j][k];             }         }         int x, y;         cin >> x >> y;         vector<vector<double>> dist = diss(place, M, x, y);         int rx, ry;         while (true)         {             bool ans = getL(dist, L, rx, ry);             if (!ans)             {                 break;             }             else             {                 L += place[rx][ry];             }         }         cout << L << endl;     }     system("pause");     return 0; }
点赞 回复 分享
发布于 2020-04-11 21:47
bool getL(vector<vector<double>> &vvi, int len, int &rx, int &ry) {     for (int i = 0; i < vvi.size(); ++i)     {         for (int j = 0; j < vvi.size(); ++j)         {             if (vvi[i][j] <= len)             {                 vvi[i][j] = int_max;                 rx = i;                 ry = j;                 return true;             }         }     }     return false; }
点赞 回复 分享
发布于 2020-04-11 21:47
#include <iostream> #include <vector> #include <cmath> using namespace std; const int int_max = 0x3f3f3f3f; double dis(int x1, int y1, int x2, int y2) {     int x = abs(x1 - x2);     int y = abs(y1 - y2);     return sqrt(pow(x, 2) + pow(y, 2)); } vector<vector<double>> diss(vector<vector<int>> vvi, int size, int x, int y) {     vector<vector<double>> res(size, vector<double>(size, int_max));     for (int i = 0; i < size; ++i)     {         for (int j = 0; j < size; ++j)         {             if (vvi[i][j] != 0)             {                 res[i][j] = dis(x, y, i, j);             }         }     }     return res; }
点赞 回复 分享
发布于 2020-04-11 21:47

相关推荐

||&nbsp;先说下主播个人情况:211本,暑期实习之前有过一段中大厂的后端实习,暑期拿过腾讯的实习offer,综合考虑业务和语言最终去了美团。实习期间体感还是不错的,5月初去的,去了就一直急着要需求做,担心因为没有产出导致转正失败,在第二个星期就和mt透露我希望能够留用。虽然第一个由于美团新人landing的友好性基本没做什么需求,但是后面也写出了小2w行的代码量(不包含单测)。中期经常主动加班赶需求,经常持续一两个星期加班到10点甚至更后面。mt对我确实不错,也是言传身教,实习期间给我讲了很多关于单测,ddd,set化等的理解,也是受益匪浅,此外在做需求的时候,也能看出把比较有含金量的部分交给我做...
菜菜菜小白菜菜菜:我在字节实习了四个月,有转正的压力所以周末大部分也在公司自学,也是因为一些原因转正拖的很久,这个点还没答辩,过段时间才回去答辩。整个不确定性的焦虑贯穿了我的秋招三个月,我也曾经犹豫过是不是应该放弃转正走秋招更快,最后因为沉没成本一直舍不得放弃,前前后后七个月真的挺累的,尤其是没有来字节实习的同学已经校招拿到意向时更加焦虑。这段时间也跟mentor聊了很多次,他告诉我未来工作上或者生活上,比这些更头疼的事情会更多,关键还是要调整好自己的心态。转正没有通过从过程上来看其实跟你自身没太大的关系,拖了三个月不出结果显然是ld的问题,并且今年美团最近的开奖大家似乎都不是很乐观,所以不去也罢。我在字节实习的时候,6月份有一个赶上春招末期的25届同事刚面进来,也拿到了小sp的薪水。不要对这件事有太大的压力,时代的问题罢了
投递美团等公司10个岗位
点赞 评论 收藏
分享
评论
1
1
分享

创作者周榜

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