반응형

문제 출처 :


https://www.acmicpc.net/problem/17254


알고리즘 분석 :


문제 해결에 필요한 사항

1. MAP


맵만 알면 문제를 빠르게 풀 수 있다.


맵의 순서는 {시간, 키보드인덱스}로 두면 자동으로 맵에 정렬되기에 순서대로 출력하면 된다.






소스 코드 : 


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
#include <iostream>
#include <cstdio>
#include <map>
 
using namespace std;
 
typedef pair<intint> pii;
 
map<pii, char> mp;
 
int main(){
  int n,m;
  scanf("%d %d",&n,&m);
 
  for(int i = 0 ; i < m; i ++){
    int a, b;
    char c;
    scanf("%d %d %c",&a,&b,&c);
 
    mp[{b,a}] = c;
  }
 
  for(auto it = mp.begin(); it != mp.end(); it++){
    printf("%c",it->second);
  }
  return 0;
}
cs


반응형

'Applied > 알고리즘 문제풀이' 카테고리의 다른 글

[1256번] K번째 접미어  (0) 2019.08.31
[SwExpertAcademy] Inversion Counting  (0) 2019.08.18
[SwExpertAcademy] 줄세우기  (0) 2019.08.07
[1251번] 하나로  (0) 2019.08.05
[4803번] 트리  (4) 2019.08.03