ACM 训练日志记录 · 思考 · 成长 提交 / 修改记录
王梓豪 / 题目列表训练档案
导出

2257B B. Gigantomachy

来源:Codeforces ★ 800

本题活力0.20按难度、完成结果与训练证据估算

算法如山行则将至

题目描述

计算谁先使对方山峰高度为0,约束是山峰高度非递增且轮流减1。

代码

#include <bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin>>t;
    while (t--) {
        int n,m;
        cin>>n>>m;
        vector<long long>a(n),b(m);
        for (int i = 0; i < n; i++) cin>>a[i];
        for (int i = 0; i < m; i++) cin>>b[i];
        long long ta = a[0]+n-1;
        long long tb = b[0]+m-1;
        if (tb <= ta) cout << 1 << '\n';
        else cout << 2 << '\n';
    }
    return 0;
}