제출 #418884

#제출 시각아이디문제언어결과실행 시간메모리
418884JediMaster11Split the Attractions (IOI19_split)C++17
0 / 100
2088 ms204 KiB
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define vint vector<int>
#define vll vector<long long>
#define fo(a, b, c) for (int a = b; a < (int)c; a++)
#define print(x) cout << x << "\n"

vint subtask1(int n, int a, int b, int c, vll roads[])
{

    vint ans;
    ans.assign(n, 0);


    int count = 0;
    int prev = -1;
    int on = 0;
    int setOn = 0;

    vector<pair<int, int>> lims;
    lims.push_back({1, a});
    lims.push_back({2, b});
    lims.push_back({3, c});

    do
    {
        count++;
        ans[on] = lims[setOn].first;

        if (count == lims[setOn].second)
        {

            setOn++;
            count = 0;
        }

        for (auto x : roads[on])
        {
            if (x != prev)
            {
                prev = on;
                on = x;
                break;
            }
        }

    } while (on != 0);

    return ans;
}

vint subtask2(int n, int a, int b, int c, vll roads[])
{

    vint ans;
    ans.assign(n, 0);
    //let a and b be contigous, so I just need to find b

    return ans;
}

// n - number of attractions
// a, b, c - size of sets a, b, c
// p, q - length m arrays containing the starts and stops of all the roads
//return an array of length n, all zeros if not possible, otherwise 1, 2 or 3 in each space
vint find_split(int n, int a, int b, int c, vint p, vint q)
{

    vint ans;

    vll roads[n];

    fo(i, 0, p.size())
    {

        roads[p[i]].push_back(q[i]);
        roads[q[i]].push_back(p[i]);
    }

    if (a == -1)
    {
        ans = subtask2(n, a, b, c, roads);
    }
    else
    {

        ans = subtask1(n, a, b, c, roads);
    }

    return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...