Submission #645620

# Submission time Handle Problem Language Result Execution time Memory
645620 2022-09-27T14:05:54 Z filiptudose7 Colors (RMI18_colors) C++14
0 / 100
3000 ms 4536 KB
#include <bits/stdc++.h>
using namespace std;
constexpr int nmax=7002;
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 3092 ms 2156 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3088 ms 4536 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3095 ms 2000 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3095 ms 2000 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3092 ms 2156 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3087 ms 2212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2270 ms 2788 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3092 ms 2156 KB Time limit exceeded
2 Halted 0 ms 0 KB -