답안 #645625

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
645625 2022-09-27T14:13:39 Z filiptudose7 Colors (RMI18_colors) C++11
47 / 100
140 ms 6176 KB
#include <bits/stdc++.h>
using namespace std;
constexpr int nmax=7005;
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 58 ms 1320 KB Output is correct
2 Correct 34 ms 1228 KB Output is correct
3 Correct 25 ms 6160 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 73 ms 1168 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 50 ms 1108 KB Output is correct
2 Correct 22 ms 1132 KB Output is correct
3 Correct 22 ms 5688 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 50 ms 1108 KB Output is correct
2 Correct 22 ms 1132 KB Output is correct
3 Correct 22 ms 5688 KB Output is correct
4 Correct 116 ms 1052 KB Output is correct
5 Runtime error 7 ms 1364 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 58 ms 1320 KB Output is correct
2 Correct 34 ms 1228 KB Output is correct
3 Correct 25 ms 6160 KB Output is correct
4 Correct 50 ms 1108 KB Output is correct
5 Correct 22 ms 1132 KB Output is correct
6 Correct 22 ms 5688 KB Output is correct
7 Correct 56 ms 900 KB Output is correct
8 Correct 33 ms 1196 KB Output is correct
9 Correct 39 ms 6176 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 140 ms 1276 KB Output is correct
2 Runtime error 6 ms 1324 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 34 ms 904 KB Output is correct
2 Correct 21 ms 1236 KB Output is correct
3 Correct 34 ms 2936 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 58 ms 1320 KB Output is correct
2 Correct 34 ms 1228 KB Output is correct
3 Correct 25 ms 6160 KB Output is correct
4 Correct 73 ms 1168 KB Output is correct
5 Correct 50 ms 1108 KB Output is correct
6 Correct 22 ms 1132 KB Output is correct
7 Correct 22 ms 5688 KB Output is correct
8 Correct 116 ms 1052 KB Output is correct
9 Runtime error 7 ms 1364 KB Execution killed with signal 11
10 Halted 0 ms 0 KB -