# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
852042 |
2023-09-21T07:15:34 Z |
allin27x |
Colors (RMI18_colors) |
C++17 |
|
3000 ms |
11676 KB |
#include <bits/stdc++.h>
using namespace std;
int a[(int)2e5];
int b[(int)2e5];
vector<int> adj[(int)2e5];
int vis[(int)2e5+7];
void dfs(int i, int v){
a[i] = v; vis[i] = v;
for (auto c: adj[i]){
if (vis[c] == v) continue;
if (b[c] > v) continue;
if (a[c] < v) continue;
dfs(c, v);
}
}
int solve(){
int n,m; cin>>n>>m;
for (int i=0; i<n; i++) vis[i] = 0;
for (int i=0; i<n; i++) adj[i].clear();
for (int i=0; i<n; i++) cin>>a[i];
for (int i=0; i<n; i++) cin>>b[i];
for (int i=0; i<m; i++){
int a,b; cin>>a>>b; a--; b--;
adj[a].push_back(b); adj[b].push_back(a);
}
for (int v = n; v; v--){
for (int i=0; i<n; i++){
if (a[i] == v && vis[i] != v) dfs(i, v);
}
}
for (int i=0; i<n; i++){
if (a[i] != b[i]) return 0;
}
return 1;
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int t; cin>>t;
while (t--){
cout << solve() << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
47 ms |
8016 KB |
Output is correct |
2 |
Correct |
24 ms |
7000 KB |
Output is correct |
3 |
Correct |
11 ms |
6744 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
58 ms |
8016 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
8016 KB |
Output is correct |
2 |
Correct |
17 ms |
6992 KB |
Output is correct |
3 |
Correct |
5 ms |
6492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
8016 KB |
Output is correct |
2 |
Correct |
17 ms |
6992 KB |
Output is correct |
3 |
Correct |
5 ms |
6492 KB |
Output is correct |
4 |
Correct |
83 ms |
9352 KB |
Output is correct |
5 |
Execution timed out |
3042 ms |
11676 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 |
24 ms |
7000 KB |
Output is correct |
3 |
Correct |
11 ms |
6744 KB |
Output is correct |
4 |
Correct |
41 ms |
8016 KB |
Output is correct |
5 |
Correct |
17 ms |
6992 KB |
Output is correct |
6 |
Correct |
5 ms |
6492 KB |
Output is correct |
7 |
Correct |
47 ms |
8016 KB |
Output is correct |
8 |
Correct |
22 ms |
7000 KB |
Output is correct |
9 |
Correct |
11 ms |
6744 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
107 ms |
9296 KB |
Output is correct |
2 |
Execution timed out |
3038 ms |
9380 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
7384 KB |
Output is correct |
2 |
Correct |
18 ms |
6744 KB |
Output is correct |
3 |
Correct |
21 ms |
6744 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
47 ms |
8016 KB |
Output is correct |
2 |
Correct |
24 ms |
7000 KB |
Output is correct |
3 |
Correct |
11 ms |
6744 KB |
Output is correct |
4 |
Correct |
58 ms |
8016 KB |
Output is correct |
5 |
Correct |
41 ms |
8016 KB |
Output is correct |
6 |
Correct |
17 ms |
6992 KB |
Output is correct |
7 |
Correct |
5 ms |
6492 KB |
Output is correct |
8 |
Correct |
83 ms |
9352 KB |
Output is correct |
9 |
Execution timed out |
3042 ms |
11676 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |