题解:P13214 [GCJ 2015 Qualification] Ominous Omino
怎么莫名其妙比别人快了 1ms 啊,成最优解了。
为简化文章,我们先设
首先排除掉
有一个比较重要也比较显然的性质,那就是放好要求图形后,当且仅当被分割成的每一个连通块大小都是
正式开始做。观察题目中给出的图发现
::::info[
::::info[
::::info[
::::info[
::::info[
//By _pig_&_buta_
//Ciallo~(∠・ω< )⌒★
//#pragma GCC optimize O(2)
#include <bits/stdc++.h>
//#define int long long
#define x first
#define y second
#define Testify 2221
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <int, pii> piii;
typedef array <int, 2> arr2;
typedef array <int, 3> arr3;
const double PI = acos (-1);
const double eps = 1e-10;
const int N = 1e5 + 10, M = 2e5 + 10;
//const int mod = 1e9 + 7;
//const int mod = 998244353;
signed main()
{
cin.tie (0), cout.tie (0);
ios :: sync_with_stdio (false);
int t; cin >> t;
for (int i = 1; i <= t; i++)
{
cout << "Case #" << i << ": ";
int x, n, m; cin >> x >> n >> m;
if (n > m) swap (n, m);
if (n * m % x) cout << "RICHARD\n";
else if (x <= 2) cout << "GABRIEL\n";
else if (x == 3)
{
if (n == 1) cout << "RICHARD\n";
else cout << "GABRIEL\n";
}
else if (x == 4)
{
if (n <= 2) cout << "RICHARD\n";
else cout << "GABRIEL\n";
}
else if (x == 5)
{
if (n <= 2) cout << "RICHARD\n";
else if (n == 3)
{
if (m >= 10) cout << "GABRIEL\n";
else cout << "RICHARD\n";
}
else cout << "GABRIEL\n";
}
else if (x == 6)
{
if (n <= 3) cout << "RICHARD\n";
else if (n >= 5) cout << "GABRIEL\n";
else cout << "GABRIEL\n";
}
else cout << "RICHARD\n";
}
return 0;
}//Ciallo~(∠·ω<)⌒☆