Additional Problems

  1. Shortest Subsequence 
  2. Counting Bits 
  3. Swap Game 
  4. Prufer Code 
  5. Acyclic Graph Edges 
  6. Strongly Connected Edges 
  7. Even Outdegree Edges 
  8. Multiplication Table 
  9. Advertisement
  10. Special Substrings 
  11. Permutation Inversions 
  12. Maximum Xor Subarray 
  13. Movie Festival Queries 
  14. Chess Tournament 
  15. Tree Traversals 
  16. Network Renovation 
  17. Graph Girth 
  18. Intersection Points 
  19. Inverse Inversions 
  20. Monotone Subsequences 
  21. String Reorder 
  22. Stack Weights 
  23. Pyramid Array 
  24. Increasing Subsequence II 
  25. String Removals 
  26. Bit Inversions 
  27. Xor Pyramid 
  28. Writing Numbers 
  29. String Transform 
  30. Letter Pair Move Game 
  31. Maximum Building I 
  32. Sorting Methods 
  33. Cyclic Array
  34. List of Sums 
  35. Increasing Array II 
  36. Food Division 
  37. Bit Problem 
  38. Swap Round Sorting 
  39. Binary Subsequences 
  40. Tree Isomorphism I 
  41. Counting Sequences 
  42. Critical Cities 
  43. School Excursion 
  44. Coin Grid 
  45. Robot Path 
  46. Programmers and Artists 
  47. Course Schedule II
  48. Removing Digits II 
  49. Coin Arrangement 
  50. Counting Bishops 
  51. Grid Puzzle I 
  52. Grid Puzzle II 
  53. Empty String 
  54. Grid Paths 
  55. Bit Substrings 
  56. Reversal Sorting 
  57. Counting Reorders 
  58. Book Shop II 
  59. Network Breakdown 
  60. Visiting Cities 
  61. Missing Coin Sum Queries 
  62. Number Grid 
  63. Maximum Building II 
  64. Filling Trominos 
  65. Stick Divisions 
  66. Coding Company 
  67. Flight Route Requests 
  68. Two Stacks Sorting 
  69. Tree Isomorphism II 
  70. Forbidden Cities 
  71. Area of Rectangles 
  72. Grid Completion 
  73. Creating Offices 
  74. Permutations II 
  75. Functional Graph Distribution 
  76. New Flight Routes 
  77. Grid Path Construction 

 

CSES Problem Set 소개 (link)

'CSES' 카테고리의 다른 글

CSES 10. Advanced Techniques  (0) 2021.07.21
CSES 9. Geometry  (0) 2021.07.21
CSES 8. String Algorithms  (0) 2021.07.21
CSES 6. Tree Algorithms  (0) 2021.07.21
CSES 5. Range Queries  (0) 2021.07.21

Advanced Techniques

 

  1. Meet in the Middle 
  2. Hamming Distance 
  3. Beautiful Subgrids 
  4. Reachable Nodes 
  5. Reachability Queries 
  6. Cut and Paste 
  7. Substring Reversals 
  8. Reversals and Sums 
  9. Necessary Roads 
  10. Necessary Cities 
  11. Eulerian Subgraphs 
  12. Monster Game I 
  13. Monster Game II 
  14. Subarray Squares 
  15. Houses and Schools 
  16. Knuth Division 
  17. Apples and Bananas 
  18. One Bit Positions 
  19. Signal Processing 
  20. New Roads Queries 
  21. Dynamic Connectivity 
  22. Parcel Delivery 
  23. Task Assignment 
  24. Distinct Routes II 

 

CSES Problem Set 소개 (link)

'CSES' 카테고리의 다른 글

CSES 11. Additional Problems  (0) 2021.07.21
CSES 9. Geometry  (0) 2021.07.21
CSES 8. String Algorithms  (0) 2021.07.21
CSES 6. Tree Algorithms  (0) 2021.07.21
CSES 5. Range Queries  (0) 2021.07.21

Geometry

  1. Point Location Test 
  2. Line Segment Intersection 
  3. Polygon Area 
  4. Point in Polygon 
  5. Polygon Lattice Points 
  6. Minimum Euclidean Distance 
  7. Convex Hull 

 

CSES Problem Set 소개 (link)

'CSES' 카테고리의 다른 글

CSES 11. Additional Problems  (0) 2021.07.21
CSES 10. Advanced Techniques  (0) 2021.07.21
CSES 8. String Algorithms  (0) 2021.07.21
CSES 6. Tree Algorithms  (0) 2021.07.21
CSES 5. Range Queries  (0) 2021.07.21

String Algorithms

  1. Word Combinations 
  2. String Matching 
  3. Finding Borders 
  4. Finding Periods 
  5. Minimal Rotation ( 1 )
  6. Longest Palindrome 
  7. Required Substring 
  8. Palindrome Queries 
  9. Finding Patterns 
  10. Counting Patterns 
  11. Pattern Positions 
  12. Distinct Substrings 
  13. Repeating Substring 
  14. String Functions 
  15. Substring Order I 
  16. Substring Order II 
  17. Substring Distribution 

 

CSES Problem Set 소개 (link)

'CSES' 카테고리의 다른 글

CSES 10. Advanced Techniques  (0) 2021.07.21
CSES 9. Geometry  (0) 2021.07.21
CSES 6. Tree Algorithms  (0) 2021.07.21
CSES 5. Range Queries  (0) 2021.07.21
CSES 3. Money Sum (1745)  (0) 2020.07.29

Tree Algorithms

  1. Subordinates
  2. Tree Matching
  3. Tree Diameter
  4. Tree Distances
  5. Tree Distances
  6. Company Queries I 
  7. Company Queries II 
  8. Distance Queries 
  9. Counting Paths 
  10. Subtree Queries 
  11. Path Queries 
  12. Path Queries II 
  13. Distinct Colors 
  14. Finding a Centroid 
  15. Fixed-Length Paths I 
  16. Fixed-Length Paths II 

 

CSES Problem Set 소개 ( https://daddysjourney.tistory.com/pages/CSES-Problems

'CSES' 카테고리의 다른 글

CSES 9. Geometry  (0) 2021.07.21
CSES 8. String Algorithms  (0) 2021.07.21
CSES 5. Range Queries  (0) 2021.07.21
CSES 3. Money Sum (1745)  (0) 2020.07.29
CSES 3. Rectangle Cutting (1744)  (0) 2020.07.28

Range Queries 

 

  1. Static Range Sum Queries
  2. Static Range Minimum Queries
  3. Dynamic Range Sum Queries
  4. Dynamic Range Minimum Queries
  5. Range Xor Queries
  6. Range Update Queries
  7. Forest Queries
  8. Hotel Queries
  9. List Removals
  10. Salary Queries
  11. Prefix Sum Queries
  12. Pizzeria Queries
  13. Subarray Sum Queries
  14. Distinct Values Queries
  15. Increasing Array Queries
  16. Forest Queries II 
  17. Range Updates and Sums
  18. Polynomial Queries
  19. Range Queries and Copies

 

CSES Problem set 소개 ( link )

'CSES' 카테고리의 다른 글

CSES 8. String Algorithms  (0) 2021.07.21
CSES 6. Tree Algorithms  (0) 2021.07.21
CSES 3. Money Sum (1745)  (0) 2020.07.29
CSES 3. Rectangle Cutting (1744)  (0) 2020.07.28
CSES 3. Edit Distance (1639)  (0) 2020.03.18

출처: https://cses.fi/problemset/task/1745


문제 설명

You have n coins with certain values. Your task is to find all money sums you can create using these coins.

입력 

The first input line has an integer n: the number of coins.

The next line has n integers x1,x2,,xn : the values of the coins.

출력

First print an integer k: the number of distinct money sums.

After this, print all possible sums in increasing order.

입력 예

4
4 2 5 2

출력 예

9
2 4 5 6 7 8 9 11 13

제약조건

1<= n <=100

1<= x_i <= 1000


문제 풀이

가능한 최대값은 100*1000 (max_n, max_xi) 이다. 가능한 최대값과 같은 크기의 boolean 배열을 만든다. 각 코인마다 값들을 더해가면서 falst->true 로 변경한다. 만들어진 배열에서 true 경우를 세고, dp[u] == true 이면, u가 가능한 값이 된다.

프로그램 내용

더보기
vector<bool> dp(n*1000+1);
...
for (int c : coins) 
{
	for (int i = dp.size() - 1; i > 0; i--) 
	{
            if (dp[i]) 
                dp[i + c] = 1; 
            d[c] = 1; 
	}
}
...

 

Dynamic Programming link )

'CSES' 카테고리의 다른 글

CSES 6. Tree Algorithms  (0) 2021.07.21
CSES 5. Range Queries  (0) 2021.07.21
CSES 3. Rectangle Cutting (1744)  (0) 2020.07.28
CSES 3. Edit Distance (1639)  (0) 2020.03.18
CSES 4. Road Reparation (1675)  (0) 2020.01.20

출처: https://cses.fi/problemset/1744


문제 설명

Given an a×b rectangle, your task is to cut it into squares. On each move you can select a rectangle and cut it into two rectangles in such a way that all side lengths remain integers. What is the minimum possible number of moves?

입력 

The only input line has two integers a and b.

출력

Print one integer: the minimum number of moves.

입력 예

3 5

출력 예

3

제약조건

1 <= a, b <= 500


문제 풀이

모두 정사각형이 되도록 직사각형을 자를때 최소 횟수를 구하는 문제이다. 가로로 자르는 경우와 세로로 자르는 경우로 나눠서 각각 한번 자를때마다, 최소값들을 갱신한다.

프로그램 내용

더보기
...   
for(int i=1; i<=a; ++i) {
	for(int j=1; j<=b; ++j) {
		if(i^j)
			dp[i][j]= INT_MAX;
		for(int k=1; k<i; ++k) // 가로로 자르는 경우
			dp[i][j]=min(dp[i][j], dp[k][j]+dp[i-k][j]+1);
		for(int k=1; k<j; ++k) // 세로로 자르는 경우
			dp[i][j]=min(dp[i][j], dp[i][k]+dp[i][j-k]+1);
	}
}
...

 

Dynamic Programming link )

'CSES' 카테고리의 다른 글

CSES 5. Range Queries  (0) 2021.07.21
CSES 3. Money Sum (1745)  (0) 2020.07.29
CSES 3. Edit Distance (1639)  (0) 2020.03.18
CSES 4. Road Reparation (1675)  (0) 2020.01.20
CSES 7. Stick Game (1729)  (0) 2020.01.19

출처:  https://cses.fi/problemset/task/1639


문제 설명

The edit distance between two strings is the minimum number of operations required to transform one string into the other.

The allowed operations are:

  • Add one character to the string.
  • Remove one character from the string.
  • Replace one character in the string.

For example, the edit distance between LOVE and MOVIE is 2, because you can first replace L with M, and then add I.

Your task is to calculate the edit distance between two strings.

입력 

The first input line has a string that contains n characters between A–Z.

The second input line has a string that contains m characters between A–Z.

출력

Print one integer: the edit distance between the strings.

입력 예

LOVE
MOVIE

출력 예

2

제약조건

1 <= n,m <= 5000


문제 풀이

두개의 문자열을 행과 열로 하는 테이블을 생각한다. src[i] == dest[j]는 변경할 필요가 없으며 값을 변경하지 않아도 된다. 문자열이 다르면, dist[i][j] = min({dist[i][j-1], dist[i-1][j], dist[i-1][j-1]) + 1 로 계속 변경해서 테이블을 완성한다.

프로그램 내용

더보기
...
for(int i=0; i <= m; ++i)
{
	for (int j=0; j <= n ; ++j)
	{
		if ( i == 0)
        	dist[i][j] = j; /// init for desStr
		else if ( j == 0)
        	dist[i][j] = i; /// init for srcStr
		else if ( srcStr[i-1] == desStr[j-1])
        	dist[i][j] = dist[i-1][j-1];
		else
        	dist[i][j] = 1 + min({	dist[i-1][j],      /// insert
									dist[i][j-1],      /// remove
									dist[i-1][j-1]});   /// replace
	}
}
...

 

Dynamic Programming link )

'CSES' 카테고리의 다른 글

CSES 3. Money Sum (1745)  (0) 2020.07.29
CSES 3. Rectangle Cutting (1744)  (0) 2020.07.28
CSES 4. Road Reparation (1675)  (0) 2020.01.20
CSES 7. Stick Game (1729)  (0) 2020.01.19
CSES 4. Road Construction (1676)  (0) 2020.01.13

출처: https://cses.fi/problemset/task/1675


문제 설명

There are n cities and mm roads between them. Unfortunately, the condition of the roads is so poor that they cannot be used. Your task is to repair some of the roads so that there will be a decent route between any two cities.

For each road, you know its reparation cost, and you should find a solution where the total cost is as small as possible.

입력 

The first input line has two integers n and m: the number of cities and roads. The cities are numbered 1,2,,n.

Then, there are m lines describing the roads. Each line has three integers a, b and c: there is a road between cities a and b, and its reparation cost is c. All roads are two-way roads.

Every road is between two different cities, and there is at most one road between two cities.

출력

Print one integer: the minimum total reparation cost. However, if there are no solutions, print "IMPOSSIBLE".

입력 예

5 6
1 2 3
2 3 5
2 4 2
3 4 8
5 1 7
5 4 4

출력 예

14

제약조건

1 <= n <= 1e5

1<= m <= 2*1e5

1 <= a, b <= n

1 <= c <= 1e9


문제 풀이

도시들을 정점으로하고 연결하는 도로들을 간선으로 하는 최소 신장 트리(Minimum Spanning Tree) 문제이다. 

간선의 비용을 기준으로 작은 것부터 도시들을 계속해서 연결해 나간다. 도시 하나를 연결할때 연결된 도시수를 기록한다. 모든 도시가 연결된다면 필요한 최소 간선의 수는 도시의 수보다 1 작은 값이 되야 한다. 이 값보다 크다면, 연결할 수 없는 도시가 존재하므로 "IMPOSSIBLE"을 출력하고, 연결되면 연결하면서 기록한 비용을 출력한다.

프로그램 내용

더보기
for(int id=0; id < tE; ++id)
{
	int a, b, c;
	cin >> a >> b >> c;
	vt.push_back({c, a, b});
}        
...
long sum = 0;
int cnt = tN;
for(int id=0; id < tE; ++id)
{
	int a, b, c;
	tie(c, a, b) = vt[id];
	if(merge(a, b))	/// union
	{
		sum += c;
		cnt--;
	}
}
...

 

 Graph Algorithms link )

'CSES' 카테고리의 다른 글

CSES 3. Rectangle Cutting (1744)  (0) 2020.07.28
CSES 3. Edit Distance (1639)  (0) 2020.03.18
CSES 7. Stick Game (1729)  (0) 2020.01.19
CSES 4. Road Construction (1676)  (0) 2020.01.13
CSES 4. Graph Algorithms  (0) 2020.01.13

+ Recent posts