int numComponents(ListNode* head, vector<int>& G) { int cc = 0; //count of connected components unordered_set<int> kk(G.begin(), G.end()); ListNode* temp = head; while(temp) { //if we find a value in LL if (inG(temp->val,kk)) { cc += 1; //keep checking the next value till you do not find value in vector, that will be the end of one cc while(temp->next && inG(temp->next->val,kk)) { temp = temp->next; } } else { temp = temp->next; } } return cc; }
int main() { freopen("1486.in","r",stdin); freopen("1486.out","w",stdout); int now=0; while(scanf("%d",&n)!=EOF) { if(n==0)break; memset(map,0,sizeof(map)); int a,b,c,d; for(int i=1;i<=n;i++) { scanf("%d%d%d%d",&a,&b,&c,&d); xmin[i]=a;xmax[i]=b; ymin[i]=c;ymax[i]=d; } for(int i=1;i<=n;i++) { scanf("%d%d",&a,&b); for(int j=1;j<=n;j++) if(inG(j,a,b)) map[j][i]=true; } printf("Heap %d\n",++now); if(!calc())printf("none\n"); else { int outn=0; for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) if(ans[i][j]) { if(outn++==0) printf("(%c,%d)",i+'A'-1,j); else printf(" (%c,%d)",i+'A'-1,j); } printf("\n"); } printf("\n"); } return 0; }