[BOJ] 10845: 큐
2022. 9. 28. 20:46
알고리즘
문제: https://www.acmicpc.net/problem/10845 #include using namespace std; queue q; string cmd; int n, k; int main() { cin >> n; for (int i = 0; i > cmd; if (cmd == "push") { cin >> k; q.push(k); } else if (cmd == "pop") { if (q.empty()) cout
[BOJ] 1874: 스택 수열
2022. 9. 28. 17:42
알고리즘
문제: https://www.acmicpc.net/problem/1874 #include using namespace std; stack s; vector v; int n; int perm[100000]; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i = 0; i > perm[i]; for (int k = 1, i = 0; k
[BOJ] 10773: 제로
2022. 9. 28. 17:08
알고리즘
문제: https://www.acmicpc.net/problem/10773 #include #include using namespace std; stack money; int k; int n; int total; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> k; for (int i = 0; i > n; (n == 0) ? money.pop() : money.push(n); } n = money.size(); for (int i = 0; i < n; i++) { total += money.top(); money.pop(); } cout
[BOJ] 10828: 스택
2022. 9. 28. 17:01
알고리즘
문제: https://www.acmicpc.net/problem/10828 #include using namespace std; stack s; string cmd; int n; int k; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i = 0; i > cmd; if (cmd == "push") { cin >> k; s.push(k); } else if (cmd == "pop") { if (s.empty()) cout
[BOJ] 1158: 요세푸스 문제
2022. 9. 28. 01:30
알고리즘
문제: https://www.acmicpc.net/problem/1158 #include using namespace std; list perm; vector result; int n, k; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> k; for (int i = 1; i
[BOJ] 5397: 키로거
2022. 9. 28. 01:15
알고리즘
문제: https://www.acmicpc.net/problem/5397 #include #include #include using namespace std; string input; int n; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i = 0; i > input; list l; list::iterator t = l.end(); for (char c : input) { switch (c) { case '': if (t == l.end()) continue; t++; break; case '-': if (t == l.begin()) continue; if (t == l.end()) { l.e..
[BOJ] 1406: 에디터
2022. 9. 28. 00:59
알고리즘
문제: https://www.acmicpc.net/problem/1406 #include #include #include using namespace std; list l; list::iterator t; string s; int n; char cmd; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> s; for (char c : s) l.push_back(c); t = l.end(); cin >> n; cin.ignore(); for (int i = 0; i > cmd; switch (cmd) { case 'L': if (t != l.begin()) t--; break; case 'D': if (t != l.end())..
[BOJ] 10808: 알파벳 개수
2022. 9. 23. 13:42
알고리즘
문제: https://www.acmicpc.net/problem/10808 #include #include using namespace std; int main() { int alpha[26] = {}; string str; cin >> str; for (char c : str) alpha[c - 'a']++; for (int value : alpha) cout
[BOJ] 3273: 두 수의 합
2022. 9. 22. 17:57
알고리즘
문제: https://www.acmicpc.net/problem/3273 : 처음 제출한 코드 #include #include using namespace std; int main() { int n, x, result = 0; int arr[100000]; cin >> n; for (int i = 0; i > arr[i]; cin >> x; for (int i = 0; i > a[i]; check[a[i]]++; } cin >> x; for (int i = ..