답안 #838518

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
838518 2023-08-27T10:22:46 Z vjudge1 Paths (BOI18_paths) C++17
23 / 100
3000 ms 1048576 KB
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const long long maxn=1e6 + 10;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n,m,k;
    cin>>n>>m>>k;
    int x[n];
    vector<int>g[n];
    for(int i=0;i<n;i++)
    {
        cin>>x[i];
        x[i]--;
    }
    for(int i=0;i<m;i++)
    {
        int l,r;
        cin>>l>>r;
        l--;r--;
        g[l].push_back(r);
        g[r].push_back(l);
    }
    int ans=0;
    for(int i=0;i<n;i++)
    {
        vector<int>c(5);
        c[x[i]]=1;
        queue<vector<int>>Q;
        Q.push({i});
        Q.push({1});
        Q.push(c);
        while(!Q.empty())
        {
            int teme=Q.front()[0];Q.pop();
            int pat=Q.front()[0];Q.pop();
            vector<int>co=Q.front();Q.pop();
            if(pat<=k && co[0]<2 && co[1]<2 && co[2]<2 && co[3]<2)
            {
                ///cout<<i<< " "<< pat<<" "<<teme<<" "<<co[0]<<endl;
                ans++;
            }
            for(auto ax:g[teme])
            {
                int col=x[ax];
                if(co[col]+1<2)
                {
                    vector<int>pomcol;
                    pomcol=co;
                    pomcol[col]++;
                    Q.push({ax});
                    Q.push({pat+1});
                    Q.push(pomcol);
                }
            }
        }
    }
    cout<<ans-n<<endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3029 ms 7196 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Execution timed out 3029 ms 7196 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 316 KB Output is correct
2 Runtime error 964 ms 1048576 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -