Educational Codeforces Round 138 (Rated for Div. 2)1749

酶和ATP 2022年11月07日 469次浏览

A. Cowardly Rooks

#include <bits/stdc++.h>
#define endl '\n'
#define int long long
using namespace std;

void solve() {
    int n, m;
    cin >> n >> m;
    vector<bool> col(n + 1, false), row(n + 1, false);
    for (int i = 1; i <= m; i++) {
        int x, y;
        cin >> x >> y;
        col[x] = true;
        row[y] = true;
    }
    int cntr = 0, cntc = 0;
    for (int i = 1; i <= n; i++) {
        if (col[i]) cntc++;
        if (row[i]) cntr++;
    }
    if (cntr == n && cntc == n)
        cout << "NO" << endl;
    else
        cout << "YES" << endl;
    return;
}

signed main() {
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int _ = 1;
    cin >> _;
    while (_--) {
        solve();
    }
    return 0;
}

B - Death's Blessing

#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#define x first
#define y second
using namespace std;

// typedef pair<int, int> PII;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n + 1), b(n + 1);
    int cnt = 0;
    int mb = -1;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        cnt += a[i];
    }
    for (int i = 1; i <= n; i++) {
        cin >> b[i];
        cnt += b[i];
        mb = max(mb, b[i]);
    }
    cout << cnt - mb << endl;
    return;
}

signed main() {
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int _ = 1;
    cin >> _;
    while (_--) {
        solve();
    }
    return 0;
}