【题解】[ABC378C] Repeating
题目传送门
Luogu | AtCoder
题意
给定长度为
思路
用数组统计每一个数最后出现的位置,但是注意到题意
代码
#include <bits/stdc++.h>
using namespace std;
#define Fast ios::sync_with_stdio(false)
#define Made return
#define By 0
#define TheSoundOfWA ;
unordered_map<int, int> mp;
int main() {
Fast;
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
int x;
cin >> x;
if (mp[x] == 0) cout << -1 << ' ';
else cout << mp[x] << ' ';
mp[x] = i;
}
Made By TheSoundOfWA
}