T1:Weak Beats

模拟

代码实现
s = input()
for i in range(1, len(s), 2):
    if s[i] == '1':
        exit(print('No'))
print('Yes')

T2:Round-Robin Tournament

模拟

代码实现
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;

int main() {
    int n;
    cin >> n;
    
    vector<string> s(n);
    rep(i, n) cin >> s[i];
    
    vector<int> w(n);
    rep(i, n) {
        rep(j, n) if (s[i][j] == 'o') w[i]++;
    }
    
    vector<int> ans(n);
    rep(i, n) ans[i] = i;
    sort(ans.begin(), ans.end(), [&](int a, int b) {
        if (w[a] == w[b]) return a < b;
        return w[a] > w[b];
    });
    
    rep(i, n) cout << ans[i]+1 << ' ';
    
    return 0;
}

T3:World Tour Finals

模拟

代码实现
#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(m);
    rep(i, m) cin >> a[i];
    
    vector<string> s(n);
    rep(i, n) cin >> s[i];
    
    vector<int> p(n);
    rep(i, n) {
        p[i] = i+1;
        rep(j, m) {
            if (s[i][j] == 'o') p[i] += a[j];
        }
    }
    int mx = *max_element(p.begin(), p.end());
    
    rep(i, n) {
        vector<int> r;
        rep(j, m) if (s[i][j] == 'x') r.push_back(a[j]);
        sort(r.begin(), r.end());
        int ans = 0;
        while (p[i] < mx) {
            p[i] += r.back();
            r.pop_back();
            ans++;
        }
        cout << ans << '\n';
    }
    
    return 0;
}

T4:Merge Slimes

每次合并最小的数,用 map 来维护数字的个数

代码实现
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;
using ll = long long;

int main() {
    int n;
    cin >> n;
    
    map<ll, ll> mp;
    rep(i, n) {
        int s, c;
        cin >> s >> c;
        mp[s] = c;
    }
    
    int ans = 0;
    while (mp.size()) {
        auto [s, c] = *mp.begin();
        mp.erase(mp.begin());
        ans += c%2;
        c /= 2;
        if (c) mp[s*2] += c;
    }
    
    cout << ans << '\n';
    
    return 0;
}

T5:Playlist

dp[t] 表示在时刻 \(t\) 开始播放新的一首歌的概率

代码实现
#include <bits/stdc++.h>
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;
using mint = modint998244353;

int main() {
    int n, x;
    cin >> n >> x;
    
    vector<int> t(n);
    rep(i, n) cin >> t[i];
    
    vector<mint> dp(x+1);
    mint p = mint(n).inv();
    dp[0] = 1;
    rep(i, x+1) {
        rep(j, n) {
            int ni = i+t[j];
            if (ni <= x) dp[ni] += dp[i]*p;
        }
    }
    
    mint ans;
    rep(i, x+1) {
        if (i+t[0] > x) {
            ans += dp[i]*p;
        }
    }
    
    cout << ans.val() << '\n';
    
    return 0;
}

T6:Push and Carry

考虑将目标位置视为原点,将行李位置视为第一象限上的点
然后分类讨论三点的相对位置关系即可

代码实现
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;
using ll = long long;

int main() {
    ll ax, ay, bx, by, cx, cy;
    cin >> ax >> ay >> bx >> by >> cx >> cy;
    ax -= cx; bx -= cx;
    ay -= cy; by -= cy;
    
    if (bx < 0) ax *= -1, bx *= -1;
    if (by < 0) ay *= -1, by *= -1;
    if (by == 0) swap(ax, ay), swap(bx, by);
    
    auto dist = [&](ll x, ll y) -> ll {
        if (ax == x and ay == y) return 0;
        ll res = abs(ax-x)+abs(ay-y);
        if (ax == x and ax == bx) {
            if ((ay < by) != (y < by)) res += 2;
        } 
        if (ay == y and ay == by) {
            if ((ax < bx) != (x < bx)) res += 2;
        } 
        return res;
    };
    
    if (bx == 0) {
        ll ans = dist(bx, by+1) + by;
        cout << ans << '\n';
        return 0;
    }
    
    ll ans = min(dist(bx, by+1), dist(bx+1, by));
    ans += bx+by+2;
    cout << ans << '\n';
    
    return 0;
}