Official

A - Conflict Editorial by en_translator


For beginners

The \(i\)-th item is wanted by both Takahashi and Aoki if and only if \(T_i\) and \(A_i\) are both o. Thus, the problem can be solved by inspecting \(i=1,2,\ldots,N\) one by one to check if there exists an \(i\) such that \(T_i=A_i\) = o.

Sample code (C++)

#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  string A, T;
  cin >> A >> T;
  for (int i = 0; i < N; i++) {
    if (T[i] == 'o' && A[i] == 'o') {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Sample code (Python)

N = int(input())
A = input()
T = input()

for i in range(N):
    if T[i] == A[i] == "o":
        print("Yes")
        exit()

print("No")

posted:
last update: