/*翻译好题意 n个变量 不超过m*2句话*/
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#define maxn 200010
using namespace std;
int n,m,f[maxn],c,s[maxn],age[maxn],sum,a,b;
vector<int>G[maxn];
bool Judge(int a,int b)
{
if(age[a]*n<sum&&age[b]*n<sum)return ;
if(age[a]*n>=sum&&age[b]*n>=sum)return ;
return ;
}
void Add(int x,int a,int y,int b)
{
x=x*+a;y=y*+b;
G[x^].push_back(y);
G[y^].push_back(x);
}
bool Dfs(int x)
{
if(f[x^])return ;if(f[x])return ;
f[x]=;s[c++]=x;
for(int i=;i<G[x].size();i++)
if(!Dfs(G[x][i]))return ;
return ;
}
bool Solve()
{
for(int i=;i<n*;i+=)
{
if(f[i]||f[i+])continue;c=;
if(!Dfs(i))
{
while(c>)f[s[--c]]=;
if(!Dfs(i+))return ;
}
}
return ;
}
int main()
{
while()
{
memset(f,,sizeof(f));sum=;
for(int i=;i<n*;i++)G[i].clear();
scanf("%d%d",&n,&m);if(n==&&m==)break;
for(int i=;i<n;i++)
scanf("%d",&age[i]),sum+=age[i];
for(int i=;i<=m;i++)
{
scanf("%d%d",&a,&b);a--;b--;
if(a==b)continue;Add(a,,b,);
if(Judge(a,b))Add(a,,b,);
}
if(Solve()==)printf("No solution\n");
else for(int i=;i<n;i++)
{
if(f[i*])printf("C\n");
else if(age[i]*n<sum)printf("B\n");
else printf("A\n");
}
}
return ;
}

最新文章

  1. APUE环境配置
  2. Javascript中String()与new String()的差异
  3. java集合类的学习(二)
  4. GNU/Linux复习笔记(1)
  5. Excel scientific notation issue
  6. fork和execve
  7. [转]centos中wget的使用方法
  8. 小王子浅读Effective javascript(一)了解javascript版本
  9. Codeforces 377
  10. DataView.RowFilter筛选DataTable中的数据
  11. 【转】Open Live Writer 插件更新
  12. android的原理,为什么不需要手动关闭程序
  13. 如何重载浏览器 onload 事件后加载的资源文件
  14. iOS 主动抛出异常
  15. JS的for循环小例子
  16. OBS 录制视频 自己留存
  17. ubuntu16下的/etc/resolv.conf重置的解决方案
  18. Paxos算法细节详解(一)
  19. 25个增强iOS应用程序性能的提示和技巧 — 中级篇
  20. javascript---我对闭包的理解

热门文章

  1. 基于cx_freeze编译PyQt4程序(numpy &amp; scipy)
  2. Java 内部类种类及使用解析
  3. 关于MYSQL优化(持续更新)
  4. js 返回前一页并刷新页面方法
  5. hdu 5072 Coprime
  6. 源代码安装GIT
  7. 可重入与线程安全(大多数Qt类是可重入,非线程安全的)
  8. .net线程入门1-进程
  9. C++中的 new / delete
  10. 数据结构(动态树):[国家集训队2012]tree(伍一鸣)