Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <cstdlib>
- #include <vector>
- using namespace std;
- int n, m, k;
- char buf[120];
- int main() {
- scanf("%d %d %d", &n, &m, &k);
- if (m == 1) {
- printf("Second\n");
- return 0;
- }
- int onlyR = 0, onlyG = 0;
- vector<int> piles;
- for (int i = 0; i < n; ++i) {
- scanf("%s", buf);
- if (m == 2 && buf[0] == buf[1] && buf[0] != '-') continue;
- int posG = -1, posR = -1;
- for (int j = 0; j < m; ++j) {
- if (buf[j] == 'G') posG = j;
- if (buf[j] == 'R') posR = j;
- }
- if (posG == -1 && posR == -1) {
- }
- else if (posG == -1) {
- onlyR += 1;
- }
- else if (posR == -1) {
- onlyG += 1;
- }
- else {
- piles.push_back(abs(posG - posR) - 1);
- }
- }
- if (onlyG > 0 && onlyR > 0) {
- printf("Draw\n");
- }
- else if (onlyG > 0) {
- printf("First\n");
- }
- else if (onlyR > 0) {
- printf("Second\n");
- }
- else {
- for (int j = 0; j < 8; ++j) {
- int cnt = 0;
- for (int pile : piles) {
- if (pile & (1 << j)) ++cnt;
- }
- if (cnt % (k + 1) != 0) {
- printf("First\n");
- return 0;
- }
- }
- printf("Second\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement