Submission #88693

# Submission time Handle Problem Language Result Execution time Memory
88693 2018-12-07T14:21:00 Z igzi Paths (BOI18_paths) C++17
100 / 100
801 ms 214644 KB
#include <bits/stdc++.h>
#define maxN 300003

using namespace std;

long long d[6][35][maxN],b[maxN],n,m,k,a,c,i,j,t,s,ans;
vector <int> adj[maxN];

int p[6]={1,2,4,8,16,32};

int main()
{
    std::ios_base::sync_with_stdio(false);
    cin>>n>>m>>k;
    for(i=0;i<n;i++){
        cin>>b[i];
        b[i]--;
        d[1][p[b[i]]][i]=1;
    }
    for(i=0;i<m;i++){
        cin>>a>>c;
        a--;
        c--;
        adj[a].push_back(c);
        adj[c].push_back(a);
    }
    for(i=2;i<=k;i++){
        for(j=0;j<n;j++){
            for(t=0;t<p[k];t++){
                if((t | p[b[j]])!=t) continue;
                for(s=0;s<adj[j].size();s++){
                    d[i][t][j]+=d[i-1][t-p[b[j]]][adj[j][s]];
                }
                //cout<<i<<" "<<t<<" "<<j<<" "<<d[i][t][j]<<endl;
            }
        }
    }
    for(i=2;i<=k;i++){
        for(j=0;j<n;j++){
            for(t=0;t<p[k];t++){
                ans+=d[i][t][j];
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Compilation message

paths.cpp: In function 'int main()':
paths.cpp:31:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 for(s=0;s<adj[j].size();s++){
                         ~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 10 ms 8056 KB Output is correct
2 Correct 10 ms 8056 KB Output is correct
3 Correct 9 ms 8056 KB Output is correct
4 Correct 8 ms 8056 KB Output is correct
5 Correct 9 ms 8056 KB Output is correct
6 Correct 9 ms 8188 KB Output is correct
7 Correct 10 ms 8188 KB Output is correct
8 Correct 9 ms 8388 KB Output is correct
9 Correct 9 ms 8388 KB Output is correct
10 Correct 8 ms 8388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 104 ms 15260 KB Output is correct
2 Correct 83 ms 16708 KB Output is correct
3 Correct 468 ms 68080 KB Output is correct
4 Correct 142 ms 68080 KB Output is correct
5 Correct 141 ms 68080 KB Output is correct
6 Correct 336 ms 68080 KB Output is correct
7 Correct 457 ms 83604 KB Output is correct
8 Correct 471 ms 88700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 8056 KB Output is correct
2 Correct 10 ms 8056 KB Output is correct
3 Correct 9 ms 8056 KB Output is correct
4 Correct 8 ms 8056 KB Output is correct
5 Correct 9 ms 8056 KB Output is correct
6 Correct 9 ms 8188 KB Output is correct
7 Correct 10 ms 8188 KB Output is correct
8 Correct 9 ms 8388 KB Output is correct
9 Correct 9 ms 8388 KB Output is correct
10 Correct 8 ms 8388 KB Output is correct
11 Correct 104 ms 15260 KB Output is correct
12 Correct 83 ms 16708 KB Output is correct
13 Correct 468 ms 68080 KB Output is correct
14 Correct 142 ms 68080 KB Output is correct
15 Correct 141 ms 68080 KB Output is correct
16 Correct 336 ms 68080 KB Output is correct
17 Correct 457 ms 83604 KB Output is correct
18 Correct 471 ms 88700 KB Output is correct
19 Correct 108 ms 88700 KB Output is correct
20 Correct 80 ms 88700 KB Output is correct
21 Correct 514 ms 97648 KB Output is correct
22 Correct 147 ms 97648 KB Output is correct
23 Correct 125 ms 97648 KB Output is correct
24 Correct 333 ms 97648 KB Output is correct
25 Correct 433 ms 112904 KB Output is correct
26 Correct 441 ms 118116 KB Output is correct
27 Correct 90 ms 118116 KB Output is correct
28 Correct 144 ms 118116 KB Output is correct
29 Correct 801 ms 202048 KB Output is correct
30 Correct 456 ms 202048 KB Output is correct
31 Correct 531 ms 202048 KB Output is correct
32 Correct 780 ms 214644 KB Output is correct
33 Correct 8 ms 214644 KB Output is correct
34 Correct 9 ms 214644 KB Output is correct
35 Correct 8 ms 214644 KB Output is correct
36 Correct 8 ms 214644 KB Output is correct
37 Correct 8 ms 214644 KB Output is correct
38 Correct 8 ms 214644 KB Output is correct
39 Correct 9 ms 214644 KB Output is correct
40 Correct 9 ms 214644 KB Output is correct
41 Correct 8 ms 214644 KB Output is correct
42 Correct 8 ms 214644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 214644 KB Output is correct
2 Correct 45 ms 214644 KB Output is correct
3 Correct 31 ms 214644 KB Output is correct
4 Correct 121 ms 214644 KB Output is correct
5 Correct 95 ms 214644 KB Output is correct
6 Correct 506 ms 214644 KB Output is correct
7 Correct 35 ms 214644 KB Output is correct
8 Correct 218 ms 214644 KB Output is correct
9 Correct 183 ms 214644 KB Output is correct
10 Correct 226 ms 214644 KB Output is correct
11 Correct 289 ms 214644 KB Output is correct
12 Correct 268 ms 214644 KB Output is correct
13 Correct 268 ms 214644 KB Output is correct
14 Correct 557 ms 214644 KB Output is correct
15 Correct 564 ms 214644 KB Output is correct
16 Correct 9 ms 214644 KB Output is correct
17 Correct 9 ms 214644 KB Output is correct
18 Correct 9 ms 214644 KB Output is correct
19 Correct 8 ms 214644 KB Output is correct
20 Correct 9 ms 214644 KB Output is correct
21 Correct 8 ms 214644 KB Output is correct
22 Correct 9 ms 214644 KB Output is correct
23 Correct 9 ms 214644 KB Output is correct
24 Correct 8 ms 214644 KB Output is correct
25 Correct 8 ms 214644 KB Output is correct