网易游戏2016在线笔试
来源:互联网 发布:软件需求分析推荐 编辑:程序博客网 时间:2024/04/28 05:23
只得了60/100
#include <cstdio>#include <cstring>#include <cstdlib> #include <algorithm> #include <iostream>#include <vector>#include <string>using namespace std;int countLevel(const string & s){ int count = 0; for(int i = 0; i < s.size(); ++i) { if(s[i] == '{') { ++count; }else if(s[i] == '}') { break; }else { } } return count + 1;}int main(){ vector<vector<string> > vector<vector<int> > vec; char* buf = (char*)malloc(10000000); int flag = 0; memset(buf, 0, 10000000); int count = 0; while(gets(buf) != NULL) { if(flag == 0) { //buf[strlen(buf) - 1] = '\0'; //time_t t1 = time(NULL); qvec.clear(); string s = buf; int level = countLevel(s); qvec.resize(level); string tmp = ""; int count = 0; for(int i = 0; i < s.size(); ++i) { if(s[i] != '{' && s[i] != ',' && s[i] != '}') { tmp += s[i]; }else if(s[i] == '{') { if(tmp != "") { qvec[count].push_back(tmp); ++count; } //++count; tmp = ""; }else if(s[i] == '}') { if(tmp != "") { qvec[count].push_back(tmp); --count; } //--count; tmp = ""; }else if(s[i] == ',') { if(tmp != "") { qvec[count].push_back(tmp); } tmp = ""; }else { // do nothing } } ++flag; }else { //time_t t1 = time(NULL); string s = buf; int level = 0; vector<int> ivec; for(int i = 0; i < qvec.size(); ++i) { for(int j = 0; j < qvec[i].size(); ++j) { if(s == qvec[i][j]) { if(find(ivec.begin(), ivec.end(), i + 1) == ivec.end()) { level = i + 1; ivec.push_back(level); } } } } flag = 0; sort(ivec.begin(), ivec.end()); vec.push_back(ivec); // time_t t2 = time(NULL); } memset(buf, 0, 10000000); } for(int i = 0; i < vec.size(); ++i) { for(int j = 0; j < vec[i].size(); ++j) { if(j == 0) { printf("%d", vec[i][j]); }else { printf(",%d ", vec[i][j]); } } printf("\n"); } free(buf); return 0;}
0 0
- 网易游戏2016在线笔试
- 2016网易游戏 游戏研发岗 在线笔试解题报告
- 2016网易游戏 游戏研发岗 在线笔试解题报告
- 网易游戏2016实习生招聘在线笔试 推箱子
- 网易游戏2016实习生招聘在线笔试:A 推箱子
- 网易2016在线笔试小结
- 2016年网易在线笔试
- 网易游戏2016校园招聘数据挖掘研究员在线笔试题和答案
- 网易游戏2016实习生招聘在线笔试——题目1 : 推箱子
- 网易游戏2015 在线笔试题(2)
- 网易游戏2015 在线笔试题(5)
- 网易游戏2015 在线笔试题(1)
- 网易游戏2015 在线笔试题(4)
- 网易游戏在线笔试(电子数字+画线)
- 2017网易游戏测试工程师-实习招聘在线笔试题
- 网易游戏2016校园招聘“游戏研发&平台开发”在线笔试——B题 Best Compression Algorithms
- 网易游戏2016校园招聘“游戏研发&平台开发”在线笔试——A题 Amusing Digits
- 网易游戏2016校园招聘“游戏研发&平台开发”在线笔试——C题 Complicated Expression
- cassandra clustering key 的查询原理
- 1.嵌入式开发环境搭建--虚拟机安装(unbutu)系统
- shell脚本 关联数组的使用
- 近期刷题题解
- SQL练习9月10
- 网易游戏2016在线笔试
- 编译器实践的重要性-专家评说
- 黑马程序员——学习日记10
- apktool + eclipse 调试smali
- Spring MVC @ResponseBody 提示 406 The resource identified by this request……
- quotation & citation
- php取整函数ceil,floor,round,intval函数的区别
- SQL练习911
- 使用ueditor,controller.jsp总报错