Rezultati

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

Test Točke Porabljen spomin Porabljen čas Status
#1 9/9 3,211 MiB 0,004 s OK
#2 9/9 3,180 MiB 0,004 s OK
#3 9/9 3,211 MiB 0,004 s OK
#4 9/9 3,211 MiB 0,004 s OK
#5 9/9 3,188 MiB 0,004 s OK
#6 9/9 3,215 MiB 0,004 s OK
#7 9/9 3,215 MiB 0,004 s OK
#8 9/9 3,215 MiB 0,004 s OK
#9 9/9 3,191 MiB 0,004 s OK
#10 9/9 3,215 MiB 0,004 s OK
#11 10/10 3,184 MiB 0,004 s OK

Ocenjevani program (Jungle_Speed.cpp):
//
//  Jungle_Speed.cpp
//  UPM-2.kolo
//
//  Created by Urban Duh on 11/05/2017.
//  Copyright Š 2017 Urban Duh. All rights reserved.
//

#include <stdio.h>
#include <iostream>
#include <list>
#include <vector>
#include <sstream>
using namespace std;

int main (){
    string s;
    int n, x;
    getline(cin, s);
    n = atoi(s.c_str());
    pair<vector<int>, vector<int> > *players = new pair<vector<int>, vector<int> >[n];
    getline(cin, s);
    stringstream ss (s);
    
    for (int i = 0; !ss.eof(); i++){ //!!!!!
        ss>>x;
        players[i%n].first.push_back(x);
    }
    
    for (int i = 0; ; i++){
        if (i == n) i = 0;
        if (players[i].first.size() == 0){
            while (!players[i].second.empty()){
                players[i].first.push_back(players[i].second[0]);
                players[i].second.erase(players[i].second.begin());
            }
        }
        players[i].second.push_back(players[i].first[players[i].first.size()-1]);
        players[i].first.pop_back();
        
        /*cout<<"Player "<<i+1<<endl;
        for (int j = 0; j < n; j++){
            for (int k = 0; k < players[j].first.size(); k++){
                cout<<players[j].first[k]<<" ";
            }
            cout<<" : ";
            for (int k = 0; k < players[j].second.size(); k++){
                cout<<players[j].second[k]<<" ";
            }
            cout<<endl;
        }
        cout<<endl;*/
        
        for (int j = 0; j < n; j++){
            if (i == j) continue;
            if (players[j].second.size() != 0 && players[i].second[players[i].second.size()-1] == players[j].second[players[j].second.size()-1]){
                while (!players[j].second.empty()){
                    players[i].first.insert(players[i].first.begin(), players[j].second[0]);
                    players[j].second.erase(players[j].second.begin());
                }
                while (!players[i].second.empty()){
                    players[i].first.insert(players[i].first.begin(), players[i].second[0]);
                    players[i].second.erase(players[i].second.begin());
                }
                i--;
                
                /*cout<<"Match! "<<i+2<<" "<<j+1<<endl;
                for (int j = 0; j < n; j++){
                    for (int k = 0; k < players[j].first.size(); k++){
                        cout<<players[j].first[k]<<" ";
                    }
                    cout<<" : ";
                    for (int k = 0; k < players[j].second.size(); k++){
                        cout<<players[j].second[k]<<" ";
                    }
                    cout<<endl;
                }
                cout<<endl;*/
                
                if (players[j].first.size() == 0 && players[j].second.size() == 0){
                    cout<<j+1;
                    return 0;
                }
                
                break;
            }
        }
    }
}