Submission #1328744

#TimeUsernameProblemLanguageResultExecution timeMemory
1328744QuocSensei철로 (IOI14_rail)C++20
0 / 100
31 ms588 KiB
#include "rail.h"
#include <bits/stdc++.h>

#define ll long long 
#define el cout << endl
#define ii pair<int, int>
#define fi first 
#define se second

using namespace std;

const int maxn = 5e3;
const int INF = 1e9;

namespace SUBTASK_1
{
    void solve(int n, int first, int location[], int type[])
    {
        for (int i = 0; i < n; i++)
        {
            if (i == 0)
            {
                type[i] = 1;
                location[i] = first;
                continue;
            }
            location[i] = getDistance(0, i) + first;
            type[i] = 2;
        }
    }
}
namespace SUBTASK_2
{
    void solve(int n, int first, int location[], int type[])
    {
        ii mn = ii(INF, INF);
        for (int i = 0; i < n; i++)
        {
            if (i == 0)
            {
                location[0] = first;
                type[i] = 1;
                continue;
            }
            mn = min(mn, ii(getDistance(0, i), i));
        }
        // cout << "OUT!", el;
        for (int i = 1; i < n; i++)
        {
            if (i != mn.se && getDistance(0, mn.se) + getDistance(mn.se, i) == getDistance(0, i))
            {
                type[i] = 1;
                location[i] = first + getDistance(0, mn.se) - getDistance(mn.se, i);
            }
            else
            {
                type[i] = 2;
                location[i] = first + getDistance(0, mn.se);
            }
            // cout << "OK: " << i << ' ' << location[i] << ' ' << type[i], el;
        }
    }
}

void findLocation(int n, int first, int location[], int stype[])
{
    SUBTASK_2::solve(n, first, location, stype);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...