Rating changes for last rounds are temporarily rolled back. They will be returned soon. ×

 
 
 
 
General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
11213781 Out of competition:
* rlac
546C - 25 GNU C++ Accepted 31 ms 15812 KB 2015-05-22 20:02:30 2015-05-22 21:45:48
→ Source
// the glory is for GOD

#include <bits/stdc++.h>

#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl;

using namespace std;

const int MAXN = 2e6;

int n, k1, k2, v, ok[MAXN], arr[MAXN], sz, msk1, msk2;
set<pair<queue<int>, queue<int> > > st;

int main ()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);    
    
    cin >> n;
    queue<int> q1, q2;

    cin >> k1;

    for (int i = 0; i < k1; ++i)
    {
        cin >> arr[sz++];
        q1.push(i);
    }

    cin >> k2;

    for (int i = 0; i < k2; ++i)
    {
        cin >> arr[sz];
        q2.push(sz++);
    }

    for (int i = 1; ; ++i) 
    {
        int v1 = q1.front(); q1.pop();
        int v2 = q2.front(); q2.pop();

        if (arr[v1] > arr[v2])
        {
            q1.push(v2);
            q1.push(v1);
        }
        else 
        {
            q2.push(v1);
            q2.push(v2);
        }

        if (q1.empty())
        {
            cout << i << " " << 2 << endl;
            return 0;
        }
        else if (q2.empty())
        {
            cout << i << " " << 1 << endl;
            return 0;
        }

        pair<queue<int>, queue<int> > p = make_pair(q1, q2);

        if (st.find(p) != st.end())
        {
            cout << -1 << endl;
            return 0;
        }      

        st.insert(p);
    }
    return 0;
}
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details