Submission #59448414 - AtCoder Beginner Contest 378

Submission #59448414


Source Code Expand

#include <bits/stdc++.h>
#include <atcoder/all>

#define all(x) (x).begin(), (x).end()
#define fix(x) fixed << setprecision(x)
#define rep(i, start, end) for (auto i = (start); (i) < (end); (i)++)
#define rrep(i, start, end) for (auto i = (start); (i) >= (end); (i)--)

constexpr auto PI = 3.14159265358979;
constexpr auto INF = 1e+9;
constexpr auto INFL = 1LL << 60;

using namespace std;
using namespace atcoder;
using ll = long long;
using lld = long double;
// using mint = modint1000000007;
using mint = modint998244353;
using Pair_int = pair<int, int>;
using Pair_ll = pair<ll, ll>;
template <class T>
using Graph = vector<vector<T>>;

template <class T1, class T2>
inline auto div_floor(T1 a, T2 b)
{
    if (b < 0)
        a *= -1, b *= -1;
    if (a >= 0)
        return a / b;
    else
        return (a + 1) / b - 1;
}
template <class T1, class T2>
inline auto div_ceil(T1 a, T2 b)
{
    if (b < 0)
        a *= -1, b *= -1;
    if (a <= 0)
        return a / b;
    else
        return (a - 1) / b + 1;
}
ll pow(ll x, ll n)
{
    ll res = 1;
    while (n > 0)
    {
        if (n & 1)
            res *= x;
        x *= x;
        n >>= 1;
    }
    return res;
}
ll pow_mod(ll x, ll n, ll mod)
{
    ll res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
ll gcd(ll x, ll y)
{
    if (x < y)
        swap(x, y);
    ll r;
    while (y > 0)
    {
        r = x % y;
        x = y;
        y = r;
    }
    return x;
}
ll lcm(ll x, ll y) { return ll(x / gcd(x, y)) * y; }
ll nCk(ll n, ll r)
{
    if (r < 0 || n < r)
        return 0;
    ll ans = 1;
    for (ll i = 1; i <= r; i++)
    {
        ans *= n--;
        ans /= i;
    }
    return ans;
}
int get_rand(int seed, int min, int max)
{
    static mt19937_64 mt64(seed);
    uniform_int_distribution<int> get_rand_int(min, max);
    return get_rand_int(mt64);
}
template <typename T>
inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template <typename T>
inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }
template <class T1, class T2>
inline auto mod(T1 x, T2 r) { return (x % r + r) % r; }

// ======================================== //

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, 0, N) cin >> A[i];

    vector<int> B(N, -1);
    unordered_map<int, int> last_pos;
    rep(i, 0, N)
    {
        if (last_pos.contains(A[i]))
            B[i] = last_pos[A[i]];

        last_pos[A[i]] = i + 1;
    }

    rep(i, 0, N) cout << B[i] << " ";
    cout << endl;

    return 0;
}

Submission Info

Submission Time
Task C - Repeating
User Yuulis
Language C++ 23 (gcc 12.2)
Score 300
Code Size 2624 Byte
Status AC
Exec Time 89 ms
Memory 14188 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 2
AC × 28
Set Name Test Cases
Sample 00_sample_01.txt, 00_sample_02.txt
All 00_sample_01.txt, 00_sample_02.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 02_handmade_01.txt, 02_handmade_02.txt, 02_handmade_03.txt, 02_handmade_04.txt, 02_handmade_05.txt, 02_handmade_06.txt
Case Name Status Exec Time Memory
00_sample_01.txt AC 1 ms 3576 KB
00_sample_02.txt AC 1 ms 3540 KB
01_random_01.txt AC 64 ms 4756 KB
01_random_02.txt AC 64 ms 4724 KB
01_random_03.txt AC 64 ms 4844 KB
01_random_04.txt AC 64 ms 4788 KB
01_random_05.txt AC 65 ms 4964 KB
01_random_06.txt AC 65 ms 4700 KB
01_random_07.txt AC 66 ms 4712 KB
01_random_08.txt AC 64 ms 4712 KB
01_random_09.txt AC 65 ms 4756 KB
01_random_10.txt AC 67 ms 4716 KB
01_random_11.txt AC 21 ms 3736 KB
01_random_12.txt AC 66 ms 4788 KB
01_random_13.txt AC 47 ms 4268 KB
01_random_14.txt AC 66 ms 4964 KB
01_random_15.txt AC 26 ms 3672 KB
01_random_16.txt AC 71 ms 7384 KB
01_random_17.txt AC 41 ms 5404 KB
01_random_18.txt AC 72 ms 7144 KB
01_random_19.txt AC 7 ms 3888 KB
01_random_20.txt AC 71 ms 7196 KB
02_handmade_01.txt AC 1 ms 3536 KB
02_handmade_02.txt AC 64 ms 4768 KB
02_handmade_03.txt AC 89 ms 14112 KB
02_handmade_04.txt AC 87 ms 14188 KB
02_handmade_05.txt AC 87 ms 14180 KB
02_handmade_06.txt AC 87 ms 14104 KB