Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <deque>
- #include <math.h>
- using namespace std;
- int main() {
- int n;
- cin >> n;
- int count = 0;
- deque<int> first_person;
- deque<int> second_person;
- for (int i = 0; i < n / 2; i++) {
- int x;
- cin >> x;
- first_person.push_back(x);
- }
- for (int j = 0; j < n / 2; j++) {
- int y;
- cin >> y;
- second_person.push_back(y);
- }
- while (true) {
- count++;
- int a = first_person.front();
- int b = second_person.front();
- first_person.pop_front();
- second_person.pop_front();
- if (a > b) {
- first_person.push_back(a);
- first_person.push_back(b);
- } else {
- first_person.pop_front();
- second_person.push_back(a);
- second_person.push_back(b);
- }
- if (a == 0 && b == n - 1) {
- second_person.push_back(a);
- second_person.push_back(b);
- }
- if (b == 0 && a == n - 1) {
- first_person.push_back(a);
- first_person.push_back(b);
- }
- if (first_person.empty()) {
- cout << "second" << count;
- return 0;
- }
- if (second_person.empty()) {
- cout << "first" << count;
- return 0;
- }
- if (count == 2 * pow(10, 5)) {
- cout << "draw";
- return 0;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement