都是模擬,沒(méi)啥好說(shuō)的。
T1注意軌道空了的時(shí)候按鈕沒(méi)反應(yīng)的,考場(chǎng)一遍過(guò)了復(fù)盤的時(shí)候給忘了改了好久。
T2題目沒(méi)說(shuō)清楚可以從任意節(jié)點(diǎn)出發(fā),以為只有0出發(fā)改了好久最后都沒(méi)改出來(lái),最后只拿了17分,不然就國(guó)二了,復(fù)盤的時(shí)候套個(gè)循環(huán)就A了,害。另外補(bǔ)充了一種并查集的解法。
T3用STL模擬,30行就可以敲出來(lái),考場(chǎng)的時(shí)候因?yàn)橥涊敵鲎铋_(kāi)始的長(zhǎng)度4,然后交上去一直全WA,想了好久沒(méi)想出來(lái)qaq
T4就是建個(gè)圖直接模擬就行,好像去年也有這種題。
L2-037 包裝機(jī) 25 69 257 0.27
L2-038 病毒溯源 25 72 277 0.26
L2-039 清點(diǎn)代碼庫(kù) 25 47 487 0.10
L2-040 哲哲打游戲 25 39 223 0.17
#include using namespace std; const int maxn = 2e4+10; string ss[1010]; int f[1010]; int main(){ int n, m, s; cin>>n>>m>>s; for(int i = 1; i <= n; i++){ cin>>ss[i]; } stackstk; int x; while(cin>>x && x!=-1){ if(x==0){ if(stk.size()==0){ continue; } cout<=ss[x].size())continue; if(stk.size()==s){ cout<1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

29
30
31
32
#include using namespace std; const int maxn = 2e4+10; vectorG[maxn]; int ans = 0, ans2=0, root=0; void dfs(int u, int h){ ans = max(ans,h); for(int v:G[u]){ dfs(v,h+1); } } int ok = 0; vectorvc; void dfs2(int u,int h){ if(ok==1)return ; if(h==ans2 && ok==0){ ok = 1; for(int i = 0; i < ans2; i++){ if(i!=0)cout<<" "<>n; for(int i = 0; i < n; i++){ int k; cin>>k; for(int j = 0; j < k; j++){ int x; cin>>x; G[i].push_back(x); } if(G[i].size()!=0)sort(G[i].begin(),G[i].end()); } for(int i = 0; i < n; i++){ dfs(i,1); if(ans>ans2){ ans2 = ans; root = i; } } cout<1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//給出一棵樹(shù),求最長(zhǎng)鏈 //并查集不要路徑壓縮,統(tǒng)計(jì)每個(gè)點(diǎn)所在的鏈 ps. 可以不是從0開(kāi)始 #include using namespace std; const int maxn = 1e5+10; int fa[maxn+10]; inline void init(int n){for(int i = 0; i < n; i++)fa[i]=i;} inline int find(int x){return x==fa[x]?x:find(fa[x]);} inline void merge(int x, int y){ if(x!=y)fa[y] = x;} int cc[maxn+10]; inline int size(int x){//TLE5 int ans = 1; while(x!=fa[x])x=fa[x],ans++; return ans; } bool cmp(vectora, vectorb){ for(int i = 0; i < a.size(); i++) if(a[i]!=b[i])return a[i]>n; init(n); for(int i = 0; i < n; i++){ int k; scanf("%d",&k); for(int j = 1; j <= k; j++){ int x; scanf("%d",&x); merge(i,x); } } //先找最長(zhǎng)鏈 int len = 1; for(int i = 0; i < n; i++){ cc[i] = size(i); len = max(len, cc[i]); } //存儲(chǔ)所有路徑,排序輸出最短 vector >ans; for(int i = 0; i < n; i++){ if(cc[i]!=len)continue; vectorvc; int x = i; while(x!=fa[x]){ vc.push_back(x); x = fa[x]; } vc.push_back(x); reverse(vc.begin(),vc.end()); ans.push_back(vc); } sort(ans.begin(),ans.end(),cmp); //cout<1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include using namespace std; const int maxn = 2e4+10; bool cmp(pair, int> a, pair, int> b){ if(a.second!=b.second)return a.second>b.second; for(int i = 0; i < a.first.size(); i++){ if(a.first[i]!=b.first[i]) return a.first[i]>n>>m; map, int>ma; for(int i = 1; i <= n; i++){ vectorvc; for(int j = 1; j <= m; j++){ int x; cin>>x; vc.push_back(x); } ma[vc]++; } vector, int> >vc(ma.begin(), ma.end()); sort(vc.begin(),vc.end(), cmp); cout<1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include using namespace std; const int maxn = 1e5+10; vectorG[maxn]; int back[110]; int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, m; cin>>n>>m; for(int i = 1; i <= n; i++){ int k; cin>>k; for(int j = 1; j <= k; j++){ int x; cin>>x; G[i].push_back(x); } } int now = 1; for(int i = 1; i <= m; i++){ int op, x; cin>>op>>x; if(op==0){ now = G[now][x-1]; }else if(op==1){ back[x] = now; cout<1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
5G游戲
版權(quán)聲明:本文內(nèi)容由網(wǎng)絡(luò)用戶投稿,版權(quán)歸原作者所有,本站不擁有其著作權(quán),亦不承擔(dān)相應(yīng)法律責(zé)任。如果您發(fā)現(xiàn)本站中有涉嫌抄襲或描述失實(shí)的內(nèi)容,請(qǐng)聯(lián)系我們jiasou666@gmail.com 處理,核實(shí)后本網(wǎng)站將在24小時(shí)內(nèi)刪除侵權(quán)內(nèi)容。