提交时间:2024-10-04 14:39:25
运行 ID: 283859
#include <bits/stdc++.h> using namespace std; int n, x, y; int a[200010]; int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; } cin >> x >> y; int sx, sy; for (int i = 1; i <= n; i++) { if (a[i] == x) sx = i; if (a[i] == y) sy = i; } cout << (abs(sx - sy) == 1 ? "Yes" : "No"); return 0; }