Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. #include <cstdio>
  2. #include <cstdlib>
  3. #include <vector>
  4. using namespace std;
  5.  
  6. int n, m, k;
  7. char buf[120];
  8.  
  9. int main() {
  10. scanf("%d %d %d", &n, &m, &k);
  11. if (m == 1) {
  12. printf("Second\n");
  13. return 0;
  14. }
  15.  
  16. int onlyR = 0, onlyG = 0;
  17. vector<int> piles;
  18.  
  19. for (int i = 0; i < n; ++i) {
  20. scanf("%s", buf);
  21. if (m == 2 && buf[0] == buf[1] && buf[0] != '-') continue;
  22.  
  23. int posG = -1, posR = -1;
  24. for (int j = 0; j < m; ++j) {
  25. if (buf[j] == 'G') posG = j;
  26. if (buf[j] == 'R') posR = j;
  27. }
  28.  
  29. if (posG == -1 && posR == -1) {
  30. }
  31. else if (posG == -1) {
  32. onlyR += 1;
  33. }
  34. else if (posR == -1) {
  35. onlyG += 1;
  36. }
  37. else {
  38. piles.push_back(abs(posG - posR) - 1);
  39. }
  40. }
  41.  
  42. if (onlyG > 0 && onlyR > 0) {
  43. printf("Draw\n");
  44. }
  45. else if (onlyG > 0) {
  46. printf("First\n");
  47. }
  48. else if (onlyR > 0) {
  49. printf("Second\n");
  50. }
  51. else {
  52. for (int j = 0; j < 8; ++j) {
  53. int cnt = 0;
  54. for (int pile : piles) {
  55. if (pile & (1 << j)) ++cnt;
  56. }
  57. if (cnt % (k + 1) != 0) {
  58. printf("First\n");
  59. return 0;
  60. }
  61. }
  62. printf("Second\n");
  63. }
  64. return 0;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement