Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
24258 | fyq & jbh's LCA | 【BJ】T3 | C++ | 运行出错 | 0 | 6 MS | 9720 KB | 1621 | 2023-12-21 10:32:14 |
#include<bits/stdc++.h> #define up(i,l,r) for(int i=(l);i<=(r);++i) #define down(i,l,r) for(int i=(l);i>=(r);--i) #define p_b push_back #define p1 first #define p2 second #define pi pair<int,int> #define m_p make_pair #define x1 x114514 #define y1 y114514 using namespace std; typedef unsigned long long ull; typedef long long ll; const int maxn=1e5+10,N=2e6,mod=1e9+7; inline int read(){ int x=0; short t=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')t=-1;ch=getchar();} while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar(); return x*t; }int n,L[maxn],t[maxn]; vector<int>C[maxn],F[maxn],P[maxn]; vector<pi>Q[maxn]; void get_col(int x){ up(i,1,L[x]){ if(!t[C[x][i]])t[C[x][i]]=1,P[x].p_b(C[x][i]); }for(int y:P[x])t[y]=0; } void slv(){ n=read(); up(i,1,n)C[i].clear(),F[i].clear(),P[i].clear(); up(i,1,1e5)Q[i].clear(); int res=1e9; up(i,1,n){ L[i]=read();C[i].resize(L[i]+5),F[i].resize(L[i]+5); up(j,1,L[i])C[i][j]=read();get_col(i); res=min(res,(int)P[i].size()+1); //for(int x:P[i])Q[x].p_b(m_p(P[i].size(),i)); }/*up(i,1,1e5)sort(Q[i].begin(),Q[i].end()); up(i,1,n){ int ll=0; for(int x:P[i]){ int mn=1e9; for(auto y:Q[x])if(y.p2!=i){mn=y.p1;break;} F[i][++ll]=mn; }sort(F[i].begin()+1,F[i].begin()+ll+1,greater<int>()); up(j,1,ll)res=min(res,F[i][j]+j); }*/cout<<res<<'\n'; } int main(){ // freopen("1.in","r",stdin); int t=read();while(t--)slv(); return 0; } /* Moyun & JBH */