Submission #856479

#TimeUsernameProblemLanguageResultExecution timeMemory
856479borisAngelovColors (RMI18_colors)C++17
0 / 100
51 ms7708 KiB
#include <bits/stdc++.h> using namespace std; const int maxn = 150005; int n, m; int a[maxn]; int b[maxn]; vector<int> g[maxn]; void reset() { for (int i = 1; i <= n; ++i) { g[i].clear(); } } void read() { cin >> n >> m; for (int i = 1; i <= n; ++i) { cin >> a[i]; } for (int i = 1; i <= n; ++i) { cin >> b[i]; } for (int i = 1; i <= m; ++i) { int x, y; cin >> x >> y; g[x].push_back(x); g[y].push_back(y); } } void solve() { for (int i = 1; i <= n; ++i) { if (a[i] > b[i]) { cout << "0\n"; return; } } vector<bool> seen(n + 5, false); for (int i = 1; i <= n; ++i) { seen[a[i]] = true; } for (int i = 1; i <= n; ++i) { if (seen[b[i]] == false) { cout << "0\n"; return; } } cout << "1\n"; } void fastIO() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } int main() { fastIO(); int q; cin >> q; while (q--) { read(); solve(); reset(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...