提交时间:2025-02-04 09:47:36

运行 ID: 363585

#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 = 0, sy = 0; 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; } //1 3 4 5 2 7 6 9 8 //