#689. LG2024TG-16

LG2024TG-16

  1. (阅读程序)
#include <bits/stdc++.h>
using namespace std;
set<int> s1={1,2,3}, s2={2,3,1,1},
         s3={1,2,100}, s4={3,4,5};
map<set<int>, int> mp1,mp2;
set<int> intersection(set<int> a, set<int> b){
  if(a.size()>b.size()) swap(a,b);
  set<int> res=a;
  for(int i:a)
    if(b.count(i)==0)
      res.erase(i);
  return res;
}

int main(){
  cout<<(s1==s2)<<endl;
  mp1[s3]=9; mp1[s1]=1;
  mp2[s2]=1; mp2[s4]=5;
  cout<<(mp1<mp2)<<' ';
  cout<<mp2[s3]<<' ';
  cout<<(mp1<=mp2)<<endl;
  mp1.clear();
  int n,l,t;
  cin>>n;
  for(int i=1;i<=n;i++){
    set<int> tmp;
    for(cin>>l;l;l--){
      cin>>t;
      tmp.emplace(t);
    }
    mp1[tmp]=i;
  }
  set<int> res=mp1.begin()->first; //第32行
  for(auto i:mp1) //第33行
    res=intersection(i.first,res);
  cout<<res.size();
  return 0;
}

假设输入的 n,l,t 满足:n 是不超过 100 的正整数,l 和 t 是不超过 1000 的正整数,完成下面的判断题和单选题。

(判断题)

代码运行后,输出的第一行是 0。( )

{{ select(1) }}

设集合 a,b 的元素个数分别为 p,q,则执行函数 intersection(a,b) 的时间复杂度为 O(min(p,q)logmax(p,q))O(min(p,q)logmax(p,q))。( )

{{ select(2) }}

将第 32 行的 begin()换成 rbegin(),运行结果可能改变( )

{{ select(3) }}

将第 33 行的 auto 换成 pair<set, int>,运行结果不变。( )

{{ select(4) }}

(选择题)

输出的第二行是( )

{{ select(5) }}

  • 0 0 0
  • 1 0 1
  • 0 1 1
  • 1 0 0

记所有输入的 l 之和为 L,则该程序最坏情况下的时间复杂度是( )

{{ select(6) }}

  • O(LlogL)O(LlogL)
  • O(Llog2L)O(Llog^2L)
  • O(nLlogL)O(nLlogL)
  • O(nLlognlogL)O(nLlognlogL)