Submission #645622

# Submission time Handle Problem Language Result Execution time Memory
645622 2022-09-27T14:06:51 Z filiptudose7 Colors (RMI18_colors) C++14
0 / 100
3000 ms 3096 KB
#include <bits/stdc++.h>
using namespace std;
constexpr int nmax=5005;
vector<int> G[nmax];
bool sel[nmax][nmax];
int a[nmax],b[nmax];
void dfs(int nod, int culoare)
{
    sel[nod][culoare]=true;
    for(auto it: G[nod])
    {
        if(sel[it][culoare]==false && a[it]>=culoare && culoare>=b[it])dfs(it,culoare);
    }
}
int main()
{
    //freopen("colors.in","r",stdin);
    //freopen("colors.out","w",stdout);
    cin.sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin>>t;
    while(t--)
    {
        int n,m;
        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(y);
            G[y].push_back(x);
        }
        for(int i=1; i<=n; ++i)
        {
            for(int j=1; j<=n; ++j)
                sel[j][i]=false;
            for(int j=1; j<=n; ++j)
            {
                if(a[j]==i && sel[j][i]==false)dfs(j,i);
            }
        }
        int rez=1;
        for(int i=1; i<=n; ++i)
        {
            if(sel[i][b[i]]==false)
            {
                rez=0;
                break;
            }
        }
        cout<<rez<<'\n';
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 3075 ms 1440 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3063 ms 3096 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3082 ms 1408 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3082 ms 1408 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3075 ms 1440 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3090 ms 1404 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2295 ms 2068 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3075 ms 1440 KB Time limit exceeded
2 Halted 0 ms 0 KB -