选择题
- 下面哪几个是质数()A. B. C. D. $$$$
- 下面的伪代码实现了什么功能()A.冒泡排序 B.选择排序 C.希尔排序 D.基数排序
4. 下面说法正确的是哪几项()A.快速排序比桶排序要快 B.费马小定理可以用欧拉定理推导出来 C.C++ 是面向对象的编程语言 D.CSP-J 是CCF举办的编程能力认证。
程序填空
” “ 表示把第 个点所在的列到第 个点所在的列的后面。
“ ” 表示询问 和 之间有几个点,如果 和 不在同一行回答 。
数据范围:
01 #include<bits/stdc++.h>
02 #define endl '\n'
03 #define int long long
04 using namespace std;
05 const int N=3e4+1;
06 ① list{
07 public:
08 int son[N],left[N],sum[N];
09 private:
10 int game_over(int);
11 int pop(int);
12 void died(int);
13 void ③(int,int);
14 bool dance(②);
15 };
16 int list::game_over(int x){
17 if(x==son[x])return x;
18 int root=game_over(son[x]);
19 left[x]+=left[son[x]];
20 return son[x]=root;
21 }
22 int list::pop(int x){
23 return left[x];
24 }
25 void list::died(int n){
26 for(int i=1;i<=n;i++)
27 son[i]=i,left[i]=0,sum[i]=1;
28 }
29 void list::③(int x,int y){
30 int sonx=game_over(x),sony=game_over(y);
31 left[sonx]+=sum[sony];
32 son[sonx]=④;
33 sum[sony]=⑤;
34 sum[sonx]=0;
35 }
36 bool list::dance(int x,int y){
37 return game_over(x)==game_over(y);
38 }
39 int n,;
40 list f;
41 signed main() {
42 ios::sync_with_stdio(false); cin.tie(nullptr);
43 cin>>n;
44 f.died(⑥);
45 for(int i=1; i<=n; i++) {
46 char ch; int x,y;
47 cin>>ch>>x>>y;
48 if(ch=='M') f.sleep(x,y);
49 else if(⑦)
50 cout<<abs(f.pop(x)-f.pop(y))-1<<endl;
51 else cout<<-1<<endl;
52 }
53 return 0;
54 }填空题
-
①:
-
②:
-
③:
-
④:
-
⑤:
-
⑥:
-
⑦: