Submission #477898

# Submission time Handle Problem Language Result Execution time Memory
477898 2021-10-04T14:21:15 Z stefantaga Colors (RMI18_colors) C++14
47 / 100
3000 ms 10512 KB
#include <bits/stdc++.h>

using namespace std;
int viz[150005],b[150005],a[150005],ok[150005],t,n,m,i,x,y,j,ok1;
vector <int> v[150005];
void dfs(int x,int culoare)
{
    viz[x]=1;
    if (b[x]==culoare)
    {
        ok[x]=1;
    }
    int i;
    for (i=0;i<v[x].size();i++)
    {
        int nod=v[x][i];
        if (viz[nod]==0&&b[nod]<=culoare&&a[nod]>=culoare)
        {
            dfs(nod,culoare);
        }
    }
}
int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(0);
    #ifdef HOME
    ifstream cin("date.in");
    ofstream cout("date.out");
    #endif // HOME
    cin>>t;
    for (;t--;)
    {
        cin>>n>>m;
        for (i=1;i<=n;i++)
        {
            cin>>a[i];
            ok[i]=0;
        }
        for (i=1;i<=n;i++)
        {
            cin>>b[i];
        }
        for (i=1;i<=n;i++)
        {
            v[i].clear();
        }
        for (i=1;i<=m;i++)
        {
            cin>>x>>y;
            v[x].push_back(y);
            v[y].push_back(x);
        }
        for (i=1;i<=n;i++)
        {
            for (j=1;j<=n;j++)
            {
                viz[j]=0;
            }
            dfs(i,a[i]);
        }
        ok1=1;
        for (i=1;i<=n;i++)
        {
            if (ok[i]==0)
            {
                ok1=0;
                break;
            }
        }
        cout<<ok1<<'\n';
    }
    return 0;
}

Compilation message

colors.cpp: In function 'void dfs(int, int)':
colors.cpp:14:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     for (i=0;i<v[x].size();i++)
      |              ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 70 ms 5256 KB Output is correct
2 Correct 36 ms 4400 KB Output is correct
3 Correct 21 ms 3988 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 101 ms 5520 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 58 ms 5344 KB Output is correct
2 Correct 21 ms 4372 KB Output is correct
3 Correct 5 ms 3856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 58 ms 5344 KB Output is correct
2 Correct 21 ms 4372 KB Output is correct
3 Correct 5 ms 3856 KB Output is correct
4 Correct 128 ms 6904 KB Output is correct
5 Execution timed out 3061 ms 10512 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 70 ms 5256 KB Output is correct
2 Correct 36 ms 4400 KB Output is correct
3 Correct 21 ms 3988 KB Output is correct
4 Correct 58 ms 5344 KB Output is correct
5 Correct 21 ms 4372 KB Output is correct
6 Correct 5 ms 3856 KB Output is correct
7 Correct 63 ms 5248 KB Output is correct
8 Correct 32 ms 4384 KB Output is correct
9 Correct 22 ms 3980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 154 ms 6960 KB Output is correct
2 Execution timed out 3079 ms 6216 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 49 ms 4560 KB Output is correct
2 Correct 28 ms 4176 KB Output is correct
3 Correct 37 ms 3988 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 70 ms 5256 KB Output is correct
2 Correct 36 ms 4400 KB Output is correct
3 Correct 21 ms 3988 KB Output is correct
4 Correct 101 ms 5520 KB Output is correct
5 Correct 58 ms 5344 KB Output is correct
6 Correct 21 ms 4372 KB Output is correct
7 Correct 5 ms 3856 KB Output is correct
8 Correct 128 ms 6904 KB Output is correct
9 Execution timed out 3061 ms 10512 KB Time limit exceeded
10 Halted 0 ms 0 KB -