当前位置:首页>文档>百度2017暑期实习生编程题及答案_2025春招题库汇总_互联网题库-1_02互联网汇总_06、百度_04、百度笔试题库

百度2017暑期实习生编程题及答案_2025春招题库汇总_互联网题库-1_02互联网汇总_06、百度_04、百度笔试题库

  • 2026-03-07 06:18:35 2026-01-26 23:37:33

文档预览

百度2017暑期实习生编程题及答案_2025春招题库汇总_互联网题库-1_02互联网汇总_06、百度_04、百度笔试题库
百度2017暑期实习生编程题及答案_2025春招题库汇总_互联网题库-1_02互联网汇总_06、百度_04、百度笔试题库
百度2017暑期实习生编程题及答案_2025春招题库汇总_互联网题库-1_02互联网汇总_06、百度_04、百度笔试题库
百度2017暑期实习生编程题及答案_2025春招题库汇总_互联网题库-1_02互联网汇总_06、百度_04、百度笔试题库
百度2017暑期实习生编程题及答案_2025春招题库汇总_互联网题库-1_02互联网汇总_06、百度_04、百度笔试题库
百度2017暑期实习生编程题及答案_2025春招题库汇总_互联网题库-1_02互联网汇总_06、百度_04、百度笔试题库

文档信息

文档格式
pdf
文档大小
1.025 MB
文档页数
6 页
上传时间
2026-01-26 23:37:33

文档内容

2 bfs #include #include #include #include #include using namespace std; char str[300]; int g[30][30]; int In[30]; int Out[30]; iinntt nnuumm[[3300]];; void init() { memset(g, 0, sizeof(g)); mmeemmsseett((IInn,, 00,, ssiizzeeooff((IInn))));; memset(Out, 0, sizeof(Out)); memset(num, 0, sizeof(num)); } bool bfs(int s,int n) { queue q;q.push(s); int mark[30]; memset(mark, 0, sizeof(mark)); while (!q.empty()) { int front = q.front(); mark[front] = 1; q.pop(); for (int i = 0; i < 30; i++) { if (g[front][i] && mark[i] == 0) { g[front][i] = 0; q.push(i); } } } int ha = 0; ffoorr ((iinntt ii == 00;; ii << 3300 ;;ii++++)) iiff ((mmaarrkk[[ii]])) hhaa++++;; if (ha==n) return true; return false; } intmain() { int n,s; //freopen("data.txt", "r", stdin); while (cin >> n) {init(); bool temp = true; for (int i = 0; i> str; int len = strlen(str); Out[str[0] - 'a']++; In[str[len - 1] - 'a']++; g[str[0] - 'a'][str[len - 1] - 'a'] = 1; g[str[len - 1] - 'a'][str[0] - 'a'] = 1; if (num[str[0] - 'a'] == 0) num[str[0] -'a'] = 1; if (num[str[len -1] - 'a'] == 0) num[str[len -1] - ''aa'']] == 11;; s = str[0] - 'a'; } int sum1 = 0; int sum2 = 0; ffoorr ((iinntt ii == 00;; ii << 3300;; ii++++)) { if ((In[i] - OOuutt[[ii]])) >>==11)) ssuumm11++++;; if ((In[i] -OOuutt[[ii]])) <<== -11)) ssuumm22++++;; iiff ((aabbss((IInn[[ii]] -OOuutt[[ii]]))>>11)) tteemmpp == ffaallssee;; } iiifff (((sssuuummm111 >>>=== 222 |||||| sssuuummm222 >>>=== 222))) ttteeemmmppp === fffaaalllssseee;;; int ha = 0; for (int i = 0; i < 30; i++) { if (num[i] == 1) ha++; } temp = temp & bfs(s,ha); if (temp) cout << "Yes" << endl; else cout << "No" << endl;} } FIFO FIFO Cache 2, 5 2 1 2 3 1 Cache (2)->(2,1)->(2,1)->(1,3)->(1,3) 1,2,4 3 Cache n mSJF, Shortest Job First “ ”””SSSPPPNNN(((SSShhhooorrrttteeesssttt PPPrrroooccceeessssss NNNeeexxxttt))) FCFS PS: : 1) 2) n ccppuu ((pp,,qq)),,pp p cpu n