比赛链接:Here
AB水题
C - Peaks
题意:
- 给出
个观察台的高度,以及
条边,定义“好观察台”:比所有直接相连的观测台都高
思路:
因为道路是双向的,互相判断一下即可
a &= bool 这个写法学习了
int main() {cin.tie(nullptr)->sync_with_stdio(false);int n, m; cin >> n >> m;vector<int>h(n), st(n, 1);for (int &i : h) cin >> i;while (m--) {int a, b;cin >> a >> b, a -= 1, b -= 1;st[a] &= h[a] > h[b];st[b] &= h[b] > h[a];}int cnt = 0;for (int i = 0; i < n; ++i) cnt += st[i];cout << cnt;}
D - I hate Factorization
题意:
- 给出
#card=math&code=X%28%5Cle1e9%29) 请问存在
#card=math&code=%28A%EF%BC%8CB%29) 使得
吗
思路:
因为 A,B可取负值,而且数据范围挺大的,说明应该有技巧
实际写了一下数据发现 取值范围应该在
之中,而且一定存在(证明不提供)
那么直接枚举就好了
ll fac(ll x) {return x * x * x * x * x;}int main() {cin.tie(nullptr)->sync_with_stdio(false);ll n; cin >> n;for (ll i = -1000; i <= 1000; ++i) {ll y = fac(i) + n;for (ll j = -1000; j <= 1000; ++j)if (fac(j) == y) {return printf("%lld %lld", j, i), 0;}}}
E - This Message Will Self-Destruct in 5s
题意:
- 给出一个长度为 n 的序列 h,
求问有多少组不同的无序数对#card=math&code=%28i%2Cj%29) 使得
思路:
思维题,题意是找数对 #card=math&code=%28i%2Cj%29) 使得
,我们不妨设讠<j,移项得:a-j=-0-,很容易想到用map存数,每次更新答案即可
我们可以设 简单移项后
map 存数即可(在ABC里做过类似的了)
int main() {cin.tie(nullptr)->sync_with_stdio(false);int n; cin >> n;int a[n + 1];ll cnt = 0;map<int, int>mp;for (int i = 1; i <= n; ++i) {cin >> a[i];cnt += mp[a[i] - i];mp[-a[i] - i] += 1;}cout << cnt ;}
