Submission #59377510


Source Code Expand

#if !__INCLUDE_LEVEL__
#include __FILE__

vector<ll> A,B;

int main(){
    ll N;cin>>N;
    A = vector<ll>(N);
    rep(i,0,N){cin>>A[i];A[i]--;}
    B = vector<ll>(N);
    rep(i,0,N)B[i] = -1;

    map<ll,ll> m;
    
    rep(i,0,N){
        if(m.count(A[i])){//A[i]が前にあったら
            B[i] = m[A[i]] + 1;
        }
        else{
            B[i] = -1;
        }
        m[A[i]] = i;
    }


    rep(i,0,N){
        cout<<B[i]<<spa;
    }
    cout<<endl;
    return 0;
}

#else
#include <bits/stdc++.h>
using namespace std;
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
struct Init { Init() { ios::sync_with_stdio(0); cin.tie(0); cout << setprecision(13); } }init;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

#define rep(i, x, limit) for (int i = (int)x; i < (int)limit; i++)
#define REP(i, x, limit) for (int i = (int)x; i <= (int)limit; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define el '\n'
#define spa " "
#define Yes cout << "Yes" << el
#define No cout << "No" << el
#define YES cout << "YES" << el
#define NO cout << "NO" << el
#define eps (1e-10)
#define Equals(a,b) (fabs((a) - (b)) < eps )

const double pi = 3.141592653589793238;
const int inf = 1073741823;
const ll infl = 1LL << 60;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";

//配列の要素を空白区切りで出力 第二引数をtrueにすると改行区切り
template<class T> inline void print_vec(const vector<T>& v, bool split_line=false) {
    if(v.empty()){
        cout << "This vector is empty." << el;
        return;
    }
    for (int i = 0; i < v.size(); i++) {
        if(v[i]==inf || v[i]==infl) cout << 'x' << " \n"[split_line || i+1==(int)v.size()];
        else cout << v[i] << " \n"[split_line || i+1==(int)v.size()];
    }
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

#endif

Submission Info

Submission Time
Task C - Repeating
User naok_000
Language C++ 23 (gcc 12.2)
Score 300
Code Size 2282 Byte
Status AC
Exec Time 104 ms
Memory 18740 KiB

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 3500 KiB
00_sample_02.txt AC 1 ms 3432 KiB
01_random_01.txt AC 21 ms 6224 KiB
01_random_02.txt AC 21 ms 6412 KiB
01_random_03.txt AC 23 ms 6356 KiB
01_random_04.txt AC 24 ms 6300 KiB
01_random_05.txt AC 24 ms 6236 KiB
01_random_06.txt AC 25 ms 6188 KiB
01_random_07.txt AC 25 ms 6244 KiB
01_random_08.txt AC 25 ms 6332 KiB
01_random_09.txt AC 25 ms 6264 KiB
01_random_10.txt AC 25 ms 6260 KiB
01_random_11.txt AC 9 ms 4216 KiB
01_random_12.txt AC 30 ms 6268 KiB
01_random_13.txt AC 21 ms 5624 KiB
01_random_14.txt AC 29 ms 6360 KiB
01_random_15.txt AC 12 ms 4428 KiB
01_random_16.txt AC 66 ms 9148 KiB
01_random_17.txt AC 36 ms 6720 KiB
01_random_18.txt AC 65 ms 9200 KiB
01_random_19.txt AC 5 ms 4104 KiB
01_random_20.txt AC 66 ms 9120 KiB
02_handmade_01.txt AC 1 ms 3452 KiB
02_handmade_02.txt AC 21 ms 6336 KiB
02_handmade_03.txt AC 104 ms 18688 KiB
02_handmade_04.txt AC 103 ms 18672 KiB
02_handmade_05.txt AC 101 ms 18740 KiB
02_handmade_06.txt AC 102 ms 18656 KiB