Rezultati

Up. imeNalogaJezikRezultatČas oddaje
qubit-2017 Jungle Speed C++ 100/100OK 11. maj '17 @ 17:24

Test Točke Porabljen spomin Porabljen čas Status
#1 9/9 3,156 MiB 0,004 s OK
#2 9/9 3,152 MiB 0,004 s OK
#3 9/9 3,152 MiB 0,004 s OK
#4 9/9 3,176 MiB 0,004 s OK
#5 9/9 3,188 MiB 0,004 s OK
#6 9/9 3,164 MiB 0,004 s OK
#7 9/9 3,164 MiB 0,004 s OK
#8 9/9 3,188 MiB 0,004 s OK
#9 9/9 3,188 MiB 0,004 s OK
#10 9/9 3,160 MiB 0,004 s OK
#11 10/10 3,160 MiB 0,004 s OK

Ocenjevani program (n2.cpp):
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <tuple>
#include <algorithm>
#include <utility>
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>

using namespace std;

typedef long long ll;

int main(void) {
    cin.tie(nullptr);
    cin.sync_with_stdio(false);

    int n;
    cin >> n;
    int m = 0;
    vector<int> karte;
    int tmp;
    while (cin >> tmp) {
        karte.push_back(tmp);
        m++;
    }
    vector<deque<int>> roke(n);
    vector<deque<int>> kupi(n);
    for (int i = 0; i < m; i++) {
        roke[i % n].push_back(karte[i]);
    }
    int turn = 0;
    int winner = -1;
    for (;winner == -1; turn = (++turn) % n) {
        if (roke[turn].size()==0) {
            roke[turn] = kupi[turn];
            kupi[turn].clear();
        }
        kupi[turn].push_front(roke[turn].back());
        roke[turn].pop_back();
        for (int i = 0; i < n; i++) {
            if (i != turn) {
                if (!kupi[i].empty() && kupi[i].front() == kupi[turn].front()) {
                    while (kupi[i].size() != 0) {
                        roke[turn].push_front(kupi[i].back());
                        kupi[i].pop_back();
                    }
                    while (kupi[turn].size() != 0) {
                        roke[turn].push_front(kupi[turn].back());
                        kupi[turn].pop_back();
                    }
                    if (roke[i].size() == 0) winner = i;
                    turn--;
                    break;
                }
            }
        }
    }
    cout << winner + 1 << endl;

    return 0;
}