广州网站优化流程/中国的搜索引擎有哪些
B. Chess Tournament
题意:n个人 每两人间进行一次比赛,结果有胜平负三种。每个人要求1.不负 或2.至少胜一场,
给出n个人的要求(1or2),求能否满足所有人的要求
思路:考虑如果只有1个2,显然不行。当至少有3个2时,假设为abc三人,显然可以a赢bb赢cc赢d。但2个2显然也不行,一开始没注意wa了一次。
// Decline is inevitable
// Romance will last forever
#include <bits/stdc++.h>
#define mst(a, x) memset(a, x, sizeof(a))
using namespace std;
const int maxn = 55;
char G[maxn][maxn];
char c[] = {'+', '=','-', 'X'};
int a[maxn];
void solve() {mst(G, 0);int n;cin >> n;string s;cin >> s;for(int i = 1; i <= n; i++)for(int j = 1; j <= n; j++)G[i][j] = i == j ? c[3] : c[1];int cnt1, cnt2;cnt1 = cnt2 = 0;for(int i =0; i < n; i++)a[i+1] = s[i] - '0';vector<int> b;for(int i = 1; i <= n; i++)if(a[i] == 2) b.push_back(i);if(b.size() == 1 || b.size() == 2)cout << "NO\n";else if(!b.size()) {cout << "YES\n";for(int i = 1; i <= n; i++){for(int j = 1; j <= n; j++) {cout << G[i][j];}cout << endl;}}else {cout << "YES\n";for(int i = 0; i < b.size(); i++) {if(i == b.size()-1) {G[b[i]][b[0]] = c[0];G[b[0]][b[i]] = c[2];break;}G[b[i]][b[i+1]] = c[0];G[b[i+1]][b[i]] = c[2];}for(int i = 1; i <= n; i++){for(int j = 1; j <= n; j++) {cout << G[i][j];}cout << endl;}}
}
int main() {int T;cin >> T;while(T--) {solve();}return 0;
}