为防止广告,目前nocow只有登录用户能够创建新页面。如要创建页面请先登录/注册(新用户需要等待1个小时才能正常使用该功能)。
Sgu/174
来自NOCOW
< Sgu
//by hza #include<cstdio> #include<map> using namespace std; const int MAX=200000+10; int n; int fa[MAX*2]; int tot; map<pair<int,int>,int>coor; int findfather(int i) { if(i==fa[i])return i; else return fa[i]=findfather(fa[i]); } int main() { #ifndef ONLINE_JUDGE freopen("174.in","r",stdin);freopen("174.out","w",stdout); #endif int sx,sy,tx,ty,i,fs,ft; scanf("%d",&n); for(i=1;i<=MAX*2-1;++i)fa[i]=i; for(i=1;i<=n;++i) { scanf("%d %d %d %d",&sx,&sy,&tx,&ty); pair<int,int>s(sx,sy); pair<int,int>t(tx,ty); if(!coor[s])coor[s]=++tot; if(!coor[t])coor[t]=++tot; fs=findfather(coor[s]); ft=findfather(coor[t]); if(fs==ft) { printf("%d\n",i); return 0; }else fa[fs]=ft; } printf("0\n"); return 0; }