반응형

문제출처

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


정렬을 이용하는 문제


소스코드

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
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
 
using namespace std;
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
 
    vector<int> v(3);
    for(int i=0; i<v.size(); i++)
        cin>>v[i];
 
    sort(v.begin(), v.end());
 
    string str;
    cin>>str;
 
    for(int i=0; i<str.length(); i++)
        cout<<v[str[i]-'A']<<" ";
 
    return 0;
}
cs




반응형

+ Recent posts