# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
858391 |
2023-10-08T10:46:35 Z |
alexdd |
Colors (RMI18_colors) |
C++17 |
|
3000 ms |
12456 KB |
#include<bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int n,m;
pair<int,int> edges[200005];
int a[200005];
int b[200005];
vector<int> con[200005];
bool good[200005];
bool visited[200005];
int mnm=INF;
void dfs(int nod)
{
visited[nod]=1;
mnm=min(mnm,a[nod]);
for(auto adj:con[nod])
if(!visited[adj] && good[adj])
dfs(adj);
}
signed main()
{
ios_base::sync_with_stdio(0);cin.tie(0);
int t;
cin>>t;
while(t--)
{
cin>>n>>m;
for(int i=1;i<=n;i++)
{
con[i].clear();
cin>>a[i];
}
for(int i=1;i<=n;i++)
cin>>b[i];
for(int i=0;i<m;i++)
{
cin>>edges[i].first>>edges[i].second;
con[edges[i].first].push_back(edges[i].second);
con[edges[i].second].push_back(edges[i].first);
}
bool bl=1;
for(int i=1;i<=n;i++)
{
if(a[i]<b[i])
{
bl=0;
break;
}
if(a[i]==b[i])
continue;
for(int j=1;j<=n;j++)
{
if(a[j]>=b[i] && b[j]<=b[i])
good[j]=1;
else
good[j]=0;
visited[j]=0;
}
mnm=INF;
dfs(i);
if(mnm!=b[i])
{
//cout<<i<<" "<<mnm<<" zzz\n";
bl=0;
break;
}
}
if(bl)
cout<<1<<"\n";
else
cout<<0<<"\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
47 ms |
8016 KB |
Output is correct |
2 |
Correct |
27 ms |
7004 KB |
Output is correct |
3 |
Correct |
19 ms |
6792 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
61 ms |
8272 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
46 ms |
8020 KB |
Output is correct |
2 |
Correct |
19 ms |
7004 KB |
Output is correct |
3 |
Correct |
5 ms |
6488 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
46 ms |
8020 KB |
Output is correct |
2 |
Correct |
19 ms |
7004 KB |
Output is correct |
3 |
Correct |
5 ms |
6488 KB |
Output is correct |
4 |
Correct |
101 ms |
9532 KB |
Output is correct |
5 |
Execution timed out |
3029 ms |
12456 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
47 ms |
8016 KB |
Output is correct |
2 |
Correct |
27 ms |
7004 KB |
Output is correct |
3 |
Correct |
19 ms |
6792 KB |
Output is correct |
4 |
Correct |
46 ms |
8020 KB |
Output is correct |
5 |
Correct |
19 ms |
7004 KB |
Output is correct |
6 |
Correct |
5 ms |
6488 KB |
Output is correct |
7 |
Correct |
52 ms |
8028 KB |
Output is correct |
8 |
Correct |
29 ms |
7004 KB |
Output is correct |
9 |
Correct |
26 ms |
6492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
119 ms |
9288 KB |
Output is correct |
2 |
Execution timed out |
3015 ms |
8796 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
25 ms |
7256 KB |
Output is correct |
2 |
Correct |
14 ms |
7040 KB |
Output is correct |
3 |
Correct |
32 ms |
6824 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
47 ms |
8016 KB |
Output is correct |
2 |
Correct |
27 ms |
7004 KB |
Output is correct |
3 |
Correct |
19 ms |
6792 KB |
Output is correct |
4 |
Correct |
61 ms |
8272 KB |
Output is correct |
5 |
Correct |
46 ms |
8020 KB |
Output is correct |
6 |
Correct |
19 ms |
7004 KB |
Output is correct |
7 |
Correct |
5 ms |
6488 KB |
Output is correct |
8 |
Correct |
101 ms |
9532 KB |
Output is correct |
9 |
Execution timed out |
3029 ms |
12456 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |