SRM668 div1 easy PaintTheRoom
考えたこと
- 全てのマスを一回ずつ通って始点に戻るような経路(ハミルトン閉路)があればその経路をぐるぐる回ればいいのでどんなKでも必ずできる
- 実験してるとRかCの片方でも偶数であればハミルトン閉路が絶対にあることがわかる
- 奇数 * 奇数のときにハミルトン閉路が存在するか考えてもなさそうという気持ちになる
- 奇数 * 奇数であったとしても全てのマスを一回ずつ通るような経路はありそう
- Rが奇数 かつ Cが奇数 かつ K>=2 のときのみcannotにしたら通った
証明できてないけど実験して反例なかったので出してしまった
AGC-Cあたりにありそう
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<ll> VL; typedef vector<VL> VVL; typedef pair<int, int> PII; #define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i) #define REP(i, n) FOR(i, 0, n) #define ALL(x) x.begin(), x.end() #define IN(a, b, x) (a<=x&&x<b) #define MP make_pair #define PB push_back const int INF = (1LL<<30); const ll LLINF = (1LL<<60); const double PI = 3.14159265359; const double EPS = 1e-12; const int MOD = 1000000007; //#define int ll template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); } template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); } int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; class PaintTheRoom { public: string canPaintEvenly(int R, int C, int K) { if(R%2 && C%2 && K >= 2) return "Cannot paint"; return "Paint"; } };