T1:Chord
模拟
代码实现
s = input()
if s in 'ACE, BDF, CEG, DFA, EGB, FAC, GBD':
print('Yes')
else:
print('No')
T2:TaK Code
模拟
代码实现
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
bool check(vector<string> s) {
rep(i, 3)rep(j, 3) if (s[i][j] != '#') return false;
rep(i, 3)rep(j, 3) if (s[8-i][8-j] != '#') return false;
rep(i, 4)rep(j, 4) {
if (i < 3 and j < 3) continue;
if (s[i][j] != '.') return false;
if (s[8-i][8-j] != '.') return false;
}
return true;
}
int main() {
int n, m;
cin >> n >> m;
vector<string> s(n);
rep(i, n) cin >> s[i];
rep(si, n-8)rep(sj, m-8) {
vector<string> t(9);
rep(i, 9)rep(j, 9) t[i] += s[si+i][sj+j];
if (check(t)) cout << si+1 << ' ' << sj+1 << '\n';
}
return 0;
}
T3:Invisible Hand
二分答案
代码实现
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<int> a(n), b(m);
rep(i, n) cin >> a[i];
rep(i, m) cin >> b[i];
int wa = 0, ac = 1001001001;
while (ac-wa > 1) {
int wj = (ac+wa)/2;
int na = 0, nb = 0;
rep(i, n) if (a[i] <= wj) na++;
rep(i, m) if (b[i] >= wj) nb++;
if (na >= nb) ac = wj; else wa = wj;
}
cout << ac << '\n';
return 0;
}