Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion caucsejunseo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
| 5์ฐจ์‹œ | 2025.04.02 | ํ | [์š”์„ธํ‘ธ์Šค๋ฌธ์ œ](https://www.acmicpc.net/problem/1158)|https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/19|
| 6์ฐจ์‹œ | 2025.04.06 | ํ | [์•ต๋ฌด์ƒˆ](https://www.acmicpc.net/problem/14713)|https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/23|
| 7์ฐจ์‹œ | 2025.04.10 | ๊ทธ๋ฆฌ๋”” | [ํด๋ฆฌ์˜ค๋ฏธ๋…ธ](https://www.acmicpc.net/problem/1343)|https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/28|
| 8์ฐจ์‹œ | 2025.04.11 | ์—ฐ๊ฒฐ๋ฆฌ์ŠคํŠธ| [ํ‚ค๋กœ๊ฑฐ](https://www.acmicpc.net/problem/5397)|https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/30/files|
| 8์ฐจ์‹œ | 2025.04.11 | ์—ฐ๊ฒฐ๋ฆฌ์ŠคํŠธ| [ํ‚ค๋กœ๊ฑฐ](https://www.acmicpc.net/problem/5397)|https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/30|
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include <string.h>

#define MAX 51
#define OUTPUT_MAX 500

int main()
{
char str[MAX];
scanf("%s", str);

char div[MAX] = { 0 };
char result[OUTPUT_MAX] = { 0 }; // ๊ฒฐ๊ณผ ์ €์žฅ์šฉ
int res_index = 0;
int i = 0, j = 0;
int len1 = strlen(str);

for (i = 0; i <= len1; i++)
{
if (str[i] == '.' || str[i] == '\0')
{
int len2 = strlen(div);

if (len2 % 2 != 0) {
printf("-1\n");
return 0; // ์ค‘๊ฐ„์— ์˜ค๋ฅ˜ ๋ฐœ์ƒ ์‹œ ์ฆ‰์‹œ ์ข…๋ฃŒ
}

for (int k = 0; k < len2 / 4; k++)
strcat(result, "AAAA");
for (int k = 0; k < (len2 % 4) / 2; k++)
strcat(result, "BB");

if (str[i] == '.')
strcat(result, ".");

memset(div, 0, sizeof(div));
j = 0;
}
else
{
div[j++] = str[i];
}
}

printf("%s\n", result); // ๋ชจ๋“  ๊ตฌ๊ฐ„ ์ฒ˜๋ฆฌ ํ›„ ์ถœ๋ ฅ

return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX 1000001

// ์—ฐ๊ฒฐ ๋ฆฌ์ŠคํŠธ ๋…ธ๋“œ ๊ตฌ์กฐ์ฒด ์ •์˜
typedef struct Node {
char data;
struct Node* prev;
struct Node* next;
} Node;

// ๋ฆฌ์ŠคํŠธ์˜ ์‹œ์ž‘๊ณผ ๋์„ ๊ด€๋ฆฌํ•˜๊ธฐ ์œ„ํ•œ ๊ตฌ์กฐ์ฒด
typedef struct {
Node* head;
Node* tail;
} List;

// ๋ฆฌ์ŠคํŠธ ์ดˆ๊ธฐํ™”
void init_list(List* list) {
list->head = NULL;
list->tail = NULL;
}

// ์ƒˆ ๋…ธ๋“œ ์‚ฝ์ž… (์ปค์„œ ๋ฐ”๋กœ ์•ž ์œ„์น˜)
void insert(List* list, Node** cursor, char ch) {
Node* new_node = (Node*)malloc(sizeof(Node));
new_node->data = ch;
new_node->prev = NULL;
new_node->next = NULL;

// ์•„๋ฌด๊ฒƒ๋„ ์—†์„ ๊ฒฝ์šฐ
if (list->head == NULL) {
list->head = list->tail = new_node;
*cursor = new_node;
return;
}

// ์ปค์„œ๊ฐ€ NULL์ด๋ฉด ๋งจ ์•ž ์‚ฝ์ž…
if (*cursor == NULL) {
new_node->next = list->head;
list->head->prev = new_node;
list->head = new_node;
*cursor = new_node;
return;
}

// ์ผ๋ฐ˜์ ์ธ ์œ„์น˜ ์‚ฝ์ž…
new_node->prev = *cursor;
new_node->next = (*cursor)->next;

if ((*cursor)->next != NULL)
(*cursor)->next->prev = new_node;
else
list->tail = new_node;

(*cursor)->next = new_node;
*cursor = new_node;
}

// ๋…ธ๋“œ ์‚ญ์ œ (์ปค์„œ ์•ž ๋…ธ๋“œ ์‚ญ์ œ)
void delete(List* list, Node** cursor) {
if (*cursor == NULL) return;

Node* to_delete = *cursor;

if (to_delete->prev != NULL)
to_delete->prev->next = to_delete->next;
else
list->head = to_delete->next;

if (to_delete->next != NULL)
to_delete->next->prev = to_delete->prev;
else
list->tail = to_delete->prev;

*cursor = to_delete->prev;
free(to_delete);
}

// ๋ฆฌ์ŠคํŠธ ์ถœ๋ ฅ
void print_list(List* list) {
Node* cur = list->head;
while (cur != NULL) {
printf("%c", cur->data);
cur = cur->next;
}
printf("\n");
}

// ๋ฉ”๋ชจ๋ฆฌ ํ•ด์ œ
void free_list(List* list) {
Node* cur = list->head;
while (cur != NULL) {
Node* temp = cur;
cur = cur->next;
free(temp);
}
list->head = list->tail = NULL;
}

int main() {
int T;
scanf("%d", &T);
while (T--) {
char input[MAX];
scanf("%s", input);

List list;
init_list(&list);
Node* cursor = NULL; // ์ปค์„œ ์ดˆ๊ธฐ ์œ„์น˜๋Š” ๊ฐ€์žฅ ์•ž

for (int i = 0; input[i]; i++) {
char ch = input[i];
if (ch == '<') {
if (cursor != NULL) cursor = cursor->prev;
}
else if (ch == '>') {
if (cursor == NULL) cursor = list.head;
else if (cursor->next != NULL) cursor = cursor->next;
}
else if (ch == '-') {
delete(&list, &cursor);
}
else {
insert(&list, &cursor, ch);
}
}

print_list(&list);
free_list(&list);
}
return 0;
}