https://www.acmicpc.net/problem/12919
#include<string>
#include<iostream>
#include<queue>
#include<algorithm>
using namespace std;
int main() {
string s, t;
queue <string> q;
cin >> s;
cin >> t;
string front1, front2;
q.push(t);
while (!q.empty()) {
front1 = q.front();
front2 = q.front();
if (q.front() == s) {
cout << 1;
return 0;
}
else if (front1.length() < s.length()) {
break;
}
reverse(front2.begin(), front2.end());
if (front1[front1.length()-1] == 'A') {
front1.erase(front1.length() - 1);
q.push(front1);
}
if (front2[front2.length()-1] == 'B') {
front2.erase(front2.length() - 1);
q.push(front2);
}
q.pop();
}
cout << 0;
}
무수한 컴파일 에러의 내용들은 stirng헤더파일의 함수인 pop_back(), back()을 쓰지말라는 내용.
백준에서는 에러를 일으키는 함수인가봐요
그래서 pop_back()은 erase()로 대체하고
back()은 맨끝 인덱스를 따로 구해줌으로써 해결!!
-------------------------------------------------------------
사실 알고보니 c++14로 제출하면 된다하더라
c++ 너무 오래된 버전이라 함수들이 없어서 컴파일에러가 났던거라고 한다,.,.
'자기개발👨💻 > 코딩 알고리즘' 카테고리의 다른 글
[python] 백준 6603 로또 (0) | 2020.08.12 |
---|---|
[c++] 백준 2669 직사각형 네개의 합집합의 면적 구하기 (0) | 2020.08.11 |
[c++] 백준 1912 연속합 (0) | 2020.08.11 |
[python] 백준 1543 문서검색 (0) | 2020.07.22 |
[python] 백준 2193 이친수 (0) | 2020.07.22 |
[c++] 백준 1085 직사각형에서 탈출 (0) | 2020.07.19 |