Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- 우선순위 큐
- 스택
- 그래프
- DFS
- 유니티
- Team Fortress 2
- 알고리즘
- 백준
- ue5
- 재귀
- 유니온 파인드
- 문자열
- 다이나믹 프로그래밍
- 브루트포스
- XR Interaction Toolkit
- 수학
- 투 포인터
- VR
- c++
- BFS
- 정렬
- 백트래킹
- 누적 합
- 자료구조
- 구현
- 그리디 알고리즘
- 시뮬레이션
- Unreal Engine 5
- 트리
- 다익스트라
Archives
- Today
- Total
1일1알
Judge - 1236 : 넌 얼마나 빠르게 왔었니? 본문
map 자료구조를 이용해서 중복된 학생의 순서들을 기록해서 풀었다.
unordered_map을 사용하니 실행속도가 더 빨랐다.
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <set>
#include <map>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <limits.h>
using namespace std;
using int64 = long long;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n, q;
cin >> n;
unordered_map<int, vector<int>> mp;
for (int i = 1; i <= n; i++) {
int num;
cin >> num;
if (mp.find(num) == mp.end()) {
mp.insert({ num,vector<int>() });
}
mp[num].push_back(i);
}
cin >> q;
for (int i = 0; i < q; i++) {
int num;
cin >> num;
if (mp.find(num) == mp.end()) {
cout << "-1" << "\n";
}
else {
for (auto a : mp[num]) {
cout << a << " ";
}
cout << "\n";
}
}
}
'알고리즘' 카테고리의 다른 글
Judge - 1231 : 양궁 선수 순위 예측 C++ (0) | 2022.07.18 |
---|---|
Judge - 1233 : 한기대 최고의 보안 시스템 C++ (0) | 2022.07.17 |
Judge - 1235 : Please In My Frontyard! C++ (0) | 2022.07.15 |
Judge - 1170 : 크리스마스의 요정 C++ (0) | 2022.07.14 |
Judge - 1237 : 2보 전진을 위한 1보 후퇴 C++ (0) | 2022.07.13 |