This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |