• 微信公众号：美女很有趣。 工作之余，放松一下，关注即送10G+美女照片！

# Educational Codeforces Round 113 (Rated for Div. 2)

1天前 10次浏览

A. Balanced Substring

```#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>

using namespace std;

const int N = 50010;

typedef pair<int, int>PII;
typedef long long LL;

int main()
{
int T;
cin >> T;
while (T--)
{
int n;
cin >> n;
string s;
cin >> s;
bool flag = false;
for (int i = 0; i < n - 1; i++)
if (s[i] != s[i + 1])
{
cout << i + 1 << ' ' << i + 2 << endl;
flag = true;
break;
}

if (!flag) cout << -1 << ' ' << -1 << endl;

}
return 0;
}```

B. Chess Tournament

```#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>

using namespace std;

typedef pair<int, int>PII;
typedef long long LL;

int main()
{
int T;
cin >> T;
while (T--)
{
int n;
cin >> n;
string s;
cin >> s;
vector<int>id;
for (int i = 0; i < n; i++)
if (s[i] == '2')
id.push_back(i);

int k = id.size();
if (k == 1 || k == 2)
{
cout << "NO" << endl;
continue;
}

vector<string> res(n, string(n, '='));//把res容量设为n，其中所有的元素都是'='
for (int i = 0; i < n; i++) res[i][i] = 'X';//对角线都是X
for (int i = 0; i < k; i++)
{
int x = id[i], y = id[(i + 1) % k];
res[x][y] = '+';
res[y][x] = '-';
}

cout << "YES" << endl;
for (int i = 0; i < n; i++) cout << res[i] << endl;
}
return 0;
}```