Loading...
2025/01/13
先に相手の隣に行ったほうが勝ちで、それは2人の差の偶奇を見ればよいです。
#include <bits/stdc++.h> using namespace std; void solve() { int n, a, b; cin >> n >> a >> b; if(abs(b-a)%2==0) cout << "YES "; else cout << "NO "; } int main() { cin.tie(0); ios::sync_with_stdio(false); int t; cin >> t; while(t--)solve(); }
素材が足りていないものが2つ以上あれば構成不可能です1。1つだけ足りていないものがある場合は、それ以外の素材の余剰のminが足りていない分を充足できるなら構成可能。全て足りているなら、自明に構成可能です。
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for (ll i=0;i<n
制約から考えると、どんな状況においてもなにか必ず構成可能な構成の仕方が一つ(以上)存在して、それを作る以外には考えられなさそうです。 手計算で試すと、全て0に合わせるパターンが入力例のテストケース1つ目と2つ目で構成可能そう2なので実装をします。テストケースが合ったのでそのまま提出するとACが取れました。謎。
#include <bits/stdc++.h> using namespace std; using ll = long long; using vll=vector<ll>; #define rep(i