답안 #854388

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
854388 2023-09-27T08:57:31 Z filiptudose7 Colors (RMI18_colors) C++11
47 / 100
118 ms 11100 KB
#include <bits/stdc++.h>
using namespace std;
constexpr int nmax=9005;
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';
        for(int i=1; i<=n; ++i)
        {
            G[i].clear();
        }
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 51 ms 4180 KB Output is correct
2 Correct 26 ms 3308 KB Output is correct
3 Correct 17 ms 11100 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 62 ms 4316 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 42 ms 4052 KB Output is correct
2 Correct 18 ms 3152 KB Output is correct
3 Correct 9 ms 11096 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 42 ms 4052 KB Output is correct
2 Correct 18 ms 3152 KB Output is correct
3 Correct 9 ms 11096 KB Output is correct
4 Correct 91 ms 5712 KB Output is correct
5 Runtime error 7 ms 1884 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 51 ms 4180 KB Output is correct
2 Correct 26 ms 3308 KB Output is correct
3 Correct 17 ms 11100 KB Output is correct
4 Correct 42 ms 4052 KB Output is correct
5 Correct 18 ms 3152 KB Output is correct
6 Correct 9 ms 11096 KB Output is correct
7 Correct 49 ms 4064 KB Output is correct
8 Correct 24 ms 3164 KB Output is correct
9 Correct 16 ms 11100 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 118 ms 5720 KB Output is correct
2 Runtime error 8 ms 1884 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 3420 KB Output is correct
2 Correct 17 ms 2904 KB Output is correct
3 Correct 28 ms 7000 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 51 ms 4180 KB Output is correct
2 Correct 26 ms 3308 KB Output is correct
3 Correct 17 ms 11100 KB Output is correct
4 Correct 62 ms 4316 KB Output is correct
5 Correct 42 ms 4052 KB Output is correct
6 Correct 18 ms 3152 KB Output is correct
7 Correct 9 ms 11096 KB Output is correct
8 Correct 91 ms 5712 KB Output is correct
9 Runtime error 7 ms 1884 KB Execution killed with signal 11
10 Halted 0 ms 0 KB -