My issue
Wrong Answer: Failed on a hidden test case
My code
#include <stdio.h>
int main() {
int n, a, b;
// Read the number of pairs
scanf("%d", &n);
// Initialize a flag to check if the pair exists
int found = 0;
// Loop through each pair
for (int i = 0; i < n; i++) {
int x, y;
// Read the current pair of integers
scanf("%d %d", &x, &y);
// Check if the pair contains both a and b in any order
if ((x == a && y == b) || (x == b && y == a)) {
found = 1;
break; // Exit the loop early if a match is found
}
}
// Read the integers a and b
scanf("%d %d", &a, &b);
// Output result based on whether a matching pair was found
if (found) {
printf("Yes\n");
} else {
printf("No\n");
}
return 0;
}
Learning course: Data structures & Algorithms lab
Problem Link: https://www.codechef.com/learn/course/muj-dsa-c/MUJDSAC19/problems/SESO05