Check if chords of a Circle are symmetric after some rotation
Last Updated : 23 Jul, 2025
Given two Integers N and M, N indicating equidistant points on circumference of a circle and M indicating number of chords formed with those points. Also given is a vector of pairs C containing position of chords. The task is to rotate the circle by any degree, say X, where 0 < X < 360, and check if the chords of are still symmetric to the original circle.
Example:
Input: N = 12, M = 6, C = {{1, 3}, {3, 7}, {5, 7}, {7, 11}, {9, 11}, {11, 3}}; Output: YES
Naive Approach: Rotate for every distance K in the range[1, N] and check for each point [a, b] if the rotated point [a + K, b + K] exits. If there exists any k then print YES else print NO Time Complexity: O(N*M)
Efficient Approach: It is enough to check for the divisors of N. Let us suppose if we rotate the image by K units then the whole image will be divided into N/K blocks. Then if K is not a divisor of N, there will be an asymmetric block of length less than K and the image will never be symmetric to the original figure. So calculate all the divisors of N and check for each chord the rotated chord exists or not.
Below is the implementation of the above approach:
Output
YES
Time Complexity: O(M*sqrt(N)*log M) Space Complexity: O(M)