Precreation contest files

This commit is contained in:
2026-02-11 11:28:23 +07:00
parent 0a8ea477bb
commit cb9f7cab30
134 changed files with 1848 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
#include <iostream>
#include <vector>
using namespace std;
void solve() {
int n;
cin >> n;
vector<int> pre(n), stu(n);
for (int &i : pre)
cin >> i;
for (int &i : stu)
cin >> i;
if (pre[n - 1] != stu[0]) {
cout << "NO\n";
return;
}
for (int i = 0; i < n - 1; i++) {
if (pre[i] < pre[i + 1]) {
cout << "NO\n";
return;
}
if (pre[i] % pre[i + 1] != 0) {
cout << "NO\n";
return;
}
}
for (int i = n - 1; i > 0; i--) {
if (stu[i] < stu[i - 1]) {
cout << "NO\n";
return;
}
if (stu[i] % stu[i - 1] != 0) {
cout << "NO\n";
return;
}
}
cout << "YES\n";
}
int main() {
int t;
cin >> t;
while (t--)
solve();
}