본문 바로가기

코드포스9

B. Alphabetical Strings ### 문제 설명 : ; A stringssof lengthnn(1≤n≤261≤n≤26) is calledalphabeticalif it can be obtained using the following algorithm: first, write an empty string toss(i.e. perform the assignmentss := ""); then perform the next stepnntimes; at theii-th step takeii-th lowercase letter of the Latin alphabet and write it either to the left of the stringssor to the right of the stringss(i.e. perform the assig.. 2021. 8. 9.
A. Shortest Path with Obstacle 문제 설명 : There are three cells on an infinite 2-dimensional grid, labeled A, B, and F. Find the length of the shortest path from A to B if: in one move you can go to any of the four adjacent cells sharing a side; visiting the cell F is forbidden (it is an obstacle). 주어진 a, b, f좌표가 있는데 f는 피하면서 가장 짧은 a - > b로의 거리를 찾는 문제였다. 틀린 이유 처음에 가장 짧은이면서 그래프가 나오길래 흥분해서 bfs로 했다. 시간초과가 발생하였다 그 이유는 t가 10^4이고 맵이 1,.. 2021. 8. 9.
A. Find The Array 문제 설명 : 어떤 배열이 있을때 ai -1, a-2 값이 배열에 있거나 ai == 1이어야한다... 그런 경우의 가장 작은 경우를 구해라.. 문제풀이 : input 예시 4 1 8 7 42 output예시: 1 3 3 7 s가 주어질때 s가 8일때 -> 1, 3, 4 가능하다 size -> 3 7일때 -> 1, 2, 4 가능하다 size -> 3 42일때 -> 1, 3, 5, 7, 9, 11, 6 1, 3, 5, 6, 7, 9, 11 가능하다 7 s 2021. 8. 9.
B2. Wonderful Coloring - 2 문제 설명 each element of the sequence is either painted in one of k colors or isn't painted; each two elements which are painted in the same color are different (i. e. there's no two equal values painted in the same color); let's calculate for each of k colors the number of elements painted in the color — all calculated numbers must be equal; the total number of painted elements of the .. 2021. 8. 5.