회원가입
로그인
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#] 어디가 틀린건지 모르겠어요...
9935번 - 문자열 폭발
yunpu1004
2년 전
0
반례라도 알려주시면 정말 감사하겠습니다!!!
using System; using System.Collections.Generic; using System.Linq; using System.Numerics; // 가장 먼저 폭발 문자열의 인덱스 위치를 찾는다 // 인덱스가 -1이 아니라면, 해당 문자열을 제거하고 다음 폭발 문자열을 찾는다 // 다음 폭발 문자열을 찾을때 매번 처음부터 탐색하면 비효율이므로, 폭발 문자열의 길이만큼 뒤로 이동해서 탐색을 시작한다 // 문자열을 매번 새로 생성하면 메모리 초과가 나므로, bool[] 을 사용해 각 문자를 배제시킨다. class Program { static void Main(string[] args) { var str = Console.ReadLine(); var included = new bool[str.Length]; var target = Console.ReadLine(); int targetLen = target.Length; int startIdx = 0; Array.Fill(included, true); int targetIdx = IndexOf(str, target, startIdx, included); while(targetIdx != -1) { int temp = targetIdx; int count = targetLen; while(count > 0) { if(included[temp]) { included[temp] = false; count--; } temp++; } startIdx = Math.Max(targetIdx - targetLen, 0); targetIdx = IndexOf(str, target, startIdx, included); } var list = new List<char>(); for(int i = 0; i < str.Length; i++) { if(included[i]) list.Add(str[i]); } if(list.Count == 0) Console.WriteLine("FRULA"); else Console.WriteLine(string.Join("", list)); } public static int IndexOf(string str, string target, int startIdx, bool[] included) { int result = -1; int count = 0; for(int i = startIdx; i < str.Length; i++) { if(!included[i]) continue; if(str[i] == target[count]) { if(count == 0) result = i; count++; if(count == target.Length) break; } else if(count != 0) { count = 0; i--; } } if(count != target.Length) result = -1; return result; } }
jyunni
2년 전
1
반례입니다.
junyunuununnnuniun un //출력: jyunni //정답: jyni
댓글을 작성하려면
로그인
해야 합니다.
yunpu1004 2년 전
반례라도 알려주시면 정말 감사하겠습니다!!!