1129

来源:互联网 发布:linux 网卡驱动 编辑:程序博客网 时间:2024/04/29 18:07

模拟水过...

#include <cstdio>#include <set>using namespace std;int main(){int n;set<int> color[26];while(scanf("%d", &n), n){for(int i = 0; i < n; ++i){color[i].clear();}int col = 0;for(int i = 0; i < n; ++i){char tmp[30], * const p = &tmp[2];scanf("%s", tmp);int check = 0;for(set<int>::iterator bgn = color[i].begin(); check < col && bgn != color[i].end() && *bgn == check; ++check, ++bgn);if(check == col){++col;}for(int j = 0; p[j]; ++j){color[p[j] - 'A'].insert(check);}}if(1 == col){printf("1 channel needed.\n");}else{printf("%d channels needed.\n", col);}}return 0;}


 

原创粉丝点击