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
- XR Interaction Toolkit
- 유니온 파인드
- 자료구조
- BFS
- 알고리즘
- ue5
- 스택
- 투 포인터
- 브루트포스
- 우선순위 큐
- 그리디 알고리즘
- DFS
- Unreal Engine 5
- 정렬
- 문자열
- 유니티
- c++
- 재귀
- 백트래킹
- 그래프
- 다이나믹 프로그래밍
- 수학
- 백준
- VR
- 구현
- 시뮬레이션
- 트리
- 누적 합
- Team Fortress 2
- 다익스트라
Archives
- Today
- Total
1일1알
백준 2149번 암호 해독 C++ 본문
https://www.acmicpc.net/problem/2149
2149번: 암호 해독
어떤 문장을 키를 이용하여 다음과 같이 암호화하려 한다. 암호화하기 전의 문장을 평문이라 하며, 암호화 된 문장은 암호문이라고 한다. 키, 평문, 암호문은 모두 영어 대문자로 된 공백 없는
www.acmicpc.net
#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;
string key, code;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> key >> code;
map<pair<char, int>, vector<char>> mp;
for (int i = 0; i < key.length(); i++) {
vector<char> v;
mp.insert({ {key[i],i},v });
}
auto it = mp.begin();
int len = code.length() / key.length();
for (int i = 0; i < key.length(); i++) {
for (int j = i * len; j < (i + 1) * len; j++) {
it->second.push_back(code[j]);
}
++it;
}
for (int i = 0; i < len; i++) {
bool print = false;
for (int j = 0; j < key.length(); j++) {
for (auto a : mp) {
if (a.first.second == j) cout << a.second[i];
}
}
}
}