131:Channel Allocation
题目链接:Channel Allocation
原理和代码部分还是懵懵懂懂
#include <iostream>
#include <vector>
#include <string>
using namespace std;
#define maxN 30
int Max=0;
int color[maxN];
vector<int> vec[maxN];
int sulotion(int n){
int minuse=0;
for (int i=0; i<n; ++i){
memset(color,0,sizeof(color));
for (int j = 1; j < vec[i].size(); j++){
int adjpos = vec[i][j];
if (vec[adjpos][0]==-1) continue;
color[vec[adjpos][0]]=1;
}
int j=-1;
//找到最小未被使用的颜色
while ( color[++j] ) ;
//着色
vec[i][0]=j;
minuse = minuse>j?minuse:j;
}
return minuse+1;
}
int main()
{
int n;
cin>>n;
string s;
whi