Submission #908770

# Submission time Handle Problem Language Result Execution time Memory
908770 2024-01-16T19:58:43 Z Andreibatman Colors (RMI18_colors) C++14
47 / 100
3000 ms 8528 KB
#include <bits/stdc++.h>
#define NMAX 150010
using namespace std;
vector<int>v[NMAX];
int a[NMAX],b[NMAX],n,m,x,y,i,j,ok,t,color,viz[NMAX],p;
queue<int>q;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>t;
    while(t--)
    {
        cin>>n>>m;
        for(i=1;i<=n;i++)
            v[i].clear();
        for(i=1;i<=n;i++)
            cin>>a[i];
        for(i=1;i<=n;i++)
            cin>>b[i];
        for(i=1;i<=m;i++)
        {
            cin>>x>>y;
            v[x].push_back(y);
            v[y].push_back(x);
        }
        for(color=n;color>=1;color--)
        {
            while(!q.empty())
                q.pop();
            for(i=1;i<=n;i++)
                if(a[i]==color)
                {
                    q.push(i);
                    viz[i]=color;
                }
            while(!q.empty())
            {
                p=q.front();
                q.pop();
                for(auto it:v[p])
                    if(viz[it]!=color && a[it]>color && a[it]>b[it])
                    {
                        a[it]=color;
                        viz[it]=color;
                        q.push(it);
                    }
            }
        }
        ok=1;
        for(i=1;i<=n;i++)
            if(a[i]!=b[i])
                ok=0;
        cout<<ok<<'\n';
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 59 ms 6996 KB Output is correct
2 Correct 37 ms 6144 KB Output is correct
3 Correct 22 ms 5692 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 64 ms 7220 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 51 ms 6948 KB Output is correct
2 Correct 27 ms 6084 KB Output is correct
3 Correct 15 ms 5468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 51 ms 6948 KB Output is correct
2 Correct 27 ms 6084 KB Output is correct
3 Correct 15 ms 5468 KB Output is correct
4 Correct 115 ms 8488 KB Output is correct
5 Execution timed out 3024 ms 7760 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 59 ms 6996 KB Output is correct
2 Correct 37 ms 6144 KB Output is correct
3 Correct 22 ms 5692 KB Output is correct
4 Correct 51 ms 6948 KB Output is correct
5 Correct 27 ms 6084 KB Output is correct
6 Correct 15 ms 5468 KB Output is correct
7 Correct 59 ms 6836 KB Output is correct
8 Correct 35 ms 6140 KB Output is correct
9 Correct 24 ms 5468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 143 ms 8528 KB Output is correct
2 Execution timed out 3041 ms 7260 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 34 ms 6244 KB Output is correct
2 Correct 19 ms 5836 KB Output is correct
3 Correct 32 ms 5708 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 59 ms 6996 KB Output is correct
2 Correct 37 ms 6144 KB Output is correct
3 Correct 22 ms 5692 KB Output is correct
4 Correct 64 ms 7220 KB Output is correct
5 Correct 51 ms 6948 KB Output is correct
6 Correct 27 ms 6084 KB Output is correct
7 Correct 15 ms 5468 KB Output is correct
8 Correct 115 ms 8488 KB Output is correct
9 Execution timed out 3024 ms 7760 KB Time limit exceeded
10 Halted 0 ms 0 KB -