Language: C++

#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <iostream>
#include <cmath>
#define INF 1LL<<5
using namespace std;
struct P{
	int x,y;
	P(){}
	P(int xx,int yy){
		x=xx;
		y=yy;
	}
	P operator +(P p){
		return P(x+p.x,y+p.y);
	}
	P operator -(P p){
		return P(x-p.x,y-p.y);
	}
	P operator *(int d){
		return P(x*d,y*d);
	}
	bool operator ==(const P &p)const{
		return (x==p.x && y==p.y);
	}
};

typedef P Vector;
typedef vector<P> Polygon;
int norm(P p){
	return p.x*p.x+p.y*p.y;
}

int dot(P a,P b){
	return a.x*b.x+a.y*b.y;
}

int cross(P a,P b){
	return a.x*b.y-a.y*b.x;
}

int ccw(P p0,P p1,P p2){
	Vector a=p1-p0;
	Vector b=p2-p0;
	if(cross(a,b)>0)return 1;
	if(cross(a,b)<0)return -1;
	if(dot(a,b)<0)return 2;
	if(norm(a)<norm(b))return -2;
	return 0;
}

bool intersect(P p1,P p2,P p3,P p4){
	if(ccw(p1,p2,p3)*ccw(p1,p2,p4)>0 || ccw(p3,p4,p1)*ccw(p3,p4,p2)>0)return false;
	if(ccw(p1,p2,p3)*ccw(p1,p2,p4)<0 && ccw(p3,p4,p1)*ccw(p3,p4,p2)<0)return true;
	if(ccw(p1,p2,p4)==0 && ccw(p1,p2,p3)==0)return true;
	if(ccw(p3,p4,p1)==0 && ccw(p3,p4,p2)==0)return true;
	if(ccw(p1,p2,p3)==0 && !(p1==p3) && !(p2==p3) && abs(ccw(p1,p2,p4))!=1)return true;
	if(ccw(p1,p2,p4)==0 && !(p1==p4) && !(p2==p4) && abs(ccw(p1,p2,p3))!=1)return true;
	return false;
}



int n;
map<string,int> id;
Polygon territory[101];
vector<int> index[101];
bool edge[11][11];
vector<int> paint;
int dp[1<<11];

bool share(int c1,int c2){
	for(int i=0;i<index[c1].size();i++){
		for(int j=0;j<index[c2].size();j++){
			int t1=index[c1][i],t2=index[c2][j];
			for(int k=0;k<territory[t1].size();k++){
				P p1=territory[t1][k];
				P p2=territory[t1][(k+1)%territory[t1].size()];
				for(int l=0;l<territory[t2].size();l++){
					P p3=territory[t2][l];
					P p4=territory[t2][(l+1)%territory[t2].size()];
					if(intersect(p1,p2,p3,p4)){
						return true;
					}
				}
			}
		}
	}
	return false;
}

int main(void){
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		int all=0;
		id.clear();
		for(int i=0;i<n;i++){
			territory[i].clear();
			index[i].clear();
		}
		for(int i=0;i<n;i++){
			string str;
			cin >> str;
			if(id.find(str)==id.end()){
				id[str]=all++;
			}
			index[id[str]].push_back(i);
			while(1){
				int x,y;
				scanf("%d",&x);
				if(x==-1)break;
				scanf("%d",&y);
				territory[i].push_back(P(x,y));
			}
		}
		memset(edge,false,sizeof(edge));
		for(int i=0;i<all;i++){
			for(int j=i+1;j<all;j++){
				if(share(i,j)){
					edge[i][j]=true;
					edge[j][i]=true;
				}
				
			}
		}
		for(int i=0;i<all;i++){
			for(int j=0;j<all;j++){
				printf("%c%c",edge[i][j]?'y':'n',j==all-1?'\n':' ');
			}
		}
		paint.clear();
		for(int i=0;i<(1<<all);i++){
			bool flag=true;
			for(int j=0;j<all;j++){
				if(!((i>>j) & 1))continue;
				for(int k=j+1;k<all;k++){
					if(!((i>>k) & 1))continue;
					if(edge[j][k])flag=false;
				}
			}
			if(flag)paint.push_back(i);
		}
		fill(dp,dp+(1<<all),INF);
		dp[0]=0;
		for(int i=0;i<(1<<all);i++){
			if(dp[i]==INF)continue;
			for(int j=0;j<paint.size();j++){
				int k=paint[j];
				dp[i|k]=min(dp[i|k],dp[i]+1);
			}
		}
		printf("%d\n",dp[(1<<all)-1]);
	}
	return 0;
}

Compiler output:
a.cc:71:22: error: 'std::vector<int> index [101]' redeclared as different kind of entity
   71 | vector<int> index[101];
      |                      ^
In file included from /usr/include/string.h:462,
                 from /usr/include/c++/14/cstring:43,
                 from a.cc:2:
/usr/include/strings.h:50:20: note: previous declaration 'const char* index(const char*, int)'
   50 | extern const char *index (const char *__s, int __c)
      |                    ^~~~~
a.cc: In function 'bool share(int, int)':
a.cc:77:28: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   77 |         for(int i=0;i<index[c1].size();i++){
      |                            ^
a.cc:78:36: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   78 |                 for(int j=0;j<index[c2].size();j++){
      |                                    ^
a.cc:79:37: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   79 |                         int t1=index[c1][i],t2=index[c2][j];
      |                                     ^
a.cc:83:57: error: 't2' was not declared in this scope; did you mean 'p2'?
   83 |                                 for(int l=0;l<territory[t2].size();l++){
      |                                                         ^~
      |                                                         p2
a.cc: In function 'int main()':
a.cc:104:30: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
  104 |                         index[i].clear();
      |                              ^
a.cc:112:30: error: invalid types '<unresolved overloaded function type>[std::map<std::__cxx11::basic_string<char>, int>::mapped_type {aka int}]' for array subscript
  112 |                         index[id[str]].push_back(i);
      |                              ^