회원가입
로그인
Toggle navigation
문제
문제
전체 문제
문제 출처
단계별로 풀어보기
알고리즘 분류
추가된 문제
문제 순위
문제
푼 사람이 한 명인 문제
아무도 못 푼 문제
최근 제출된 문제
최근 풀린 문제
랜덤
출처
ICPC
Olympiad
한국정보올림피아드
한국정보올림피아드시․도지역본선
전국 대학생 프로그래밍 대회 동아리 연합
대학교 대회
카카오 코드 페스티벌
Coder's High
ICPC
Regionals
World Finals
Korea Regional
Africa and the Middle East Regionals
Europe Regionals
Latin America Regionals
North America Regionals
South Pacific Regionals
문제집
대회
채점 현황
게시판
그룹
더 보기
재채점 기록
블로그
도움말
전체
공지
자유
질문
오타/오역/요청
게시판 공지
홍보
업데이트
solved.ac
글쓰기
질문 도움말
자주묻는 질문
c언어 시간초과뜨는 이유 알려주세요
1406번 - 에디터
practice430
2년 전
0
테케는 맞는데 시간초과가 뜹니다
#pragma warning (disable: 4996) #define _CRT_NO_SECURE_WARNINGS #include<stdio.h> #include<string.h> #include<stdlib.h> #include<math.h> struct node { char index; struct node* next; struct node* pre; }; struct node nodepool[600005]; struct node head; struct node tail; struct node* cursor = &tail; int nodepoolcnt = 1; int size = 0; void init() { head.next = &tail; tail.pre = &head; } void print() { struct node* p = head.next; while (p != &tail) { printf("%c", p->index); p = p->next; } } void insert(char x) { nodepool[nodepoolcnt].index = x; nodepool[nodepoolcnt].pre = tail.pre; tail.pre->next = &nodepool[nodepoolcnt]; nodepool[nodepoolcnt].next = &tail; tail.pre = &nodepool[nodepoolcnt++]; } void L() { if (cursor != head.next) { cursor = cursor->pre; } } void D() { if (cursor != &tail) { cursor = cursor->next; } } void B() { if (cursor != head.next) { cursor = cursor->pre; cursor->pre->next = cursor->next; cursor->next->pre = cursor->pre; cursor = cursor->next; } } void P(char s) { nodepool[nodepoolcnt].index = s; nodepool[nodepoolcnt].pre = cursor->pre; cursor->pre->next = &nodepool[nodepoolcnt]; nodepool[nodepoolcnt].next = cursor; cursor->pre = &nodepool[nodepoolcnt++]; } char str[100005]; int n, m; char order; char letter; int main() { scanf(" %s", str); init(); for (int i = 0; i < strlen(str); i++) { insert(str[i]); } scanf("%d", &m); for (int i = 0; i < m; i++) { scanf(" %c", &order); if (order == 'L') { L(); } else if (order == 'D') { D(); } else if (order == 'B') { B(); } else if (order == 'P') { scanf(" %c", &letter); P(letter); } } print(); }
protarie
2년 전
0
시간제한이 0.3초인 점을 확인해주세요.
댓글을 작성하려면
로그인
해야 합니다.
practice430 2년 전
테케는 맞는데 시간초과가 뜹니다