# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
108087 |
2019-04-27T09:14:47 Z |
Abelyan |
Paths (BOI18_paths) |
C++17 |
|
719 ms |
170360 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i,a) for (int i=0;i<(a);++i)
#define FORD(i,a) for (int i=(a)-1;i>=0;i--)
#define FORT(i,a,b) for (int i=(a);i<=(b);++i)
#define FORTD(i,b,a) for (int i=(b);i>=(a);--i)
#define trav(i,v) for (auto i : v)
#define all(v) v.begin(),v.end()
#define ad push_back
#define fr first
#define sc second
#define mpr(a,b) make_pair(a,b)
#define pir pair<int,int>
#define all(v) v.begin(),v.end()
#define make_unique(v) v.erase(unique(all(v),v.end()))
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define dbg(x);
#define dbgv(v);
#define srng mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define y1 EsiHancagorcRepa
#ifdef ALEXPC
#define dbg(x); cout<<#x<<" = "<<x<<endl
#define dbgv(v); cout<<#v<<" = ["; trav(tv,v)cout<<"tv,";cout<<"]"<<endl
#endif
const int N=3*1e5+6;
const ll MOD=1000*1000*1000+7;
int f[N];
ll dp[N][65];
vector<int> g[N];
void rec(int v,int mask){
if (dp[v][mask]!=-1)return;
dp[v][mask]=1;
trav(to,g[v]){
if (f[to]&mask)continue;
rec(to,mask+f[to]);
dp[v][mask]+=dp[to][mask+f[to]];
//cout<<v<<" "<<mask<<" "<<dp[to][ma]
}
}
int main(){
fastio;
srng;
int n, m, k;
cin >> n >> m >> k;
FOR(i, n) {
cin >> f[i+1];
f[i+1]--;
f[i+1]=(1<<f[i+1]);
FOR(j,31)dp[i+1][j]=-1;
}
FOR(i, m) {
int a, b;
cin >> a >> b;
g[a].push_back(b);
g[b].push_back(a);
}
ll ans=0;
FORT(i,1,n){
rec(i,f[i]);
ans+=dp[i][f[i]];
}
cout<<ans-n<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
7424 KB |
Output is correct |
2 |
Correct |
8 ms |
7424 KB |
Output is correct |
3 |
Correct |
8 ms |
7424 KB |
Output is correct |
4 |
Correct |
8 ms |
7424 KB |
Output is correct |
5 |
Correct |
8 ms |
7424 KB |
Output is correct |
6 |
Correct |
8 ms |
7424 KB |
Output is correct |
7 |
Correct |
9 ms |
7424 KB |
Output is correct |
8 |
Correct |
8 ms |
7424 KB |
Output is correct |
9 |
Correct |
8 ms |
7424 KB |
Output is correct |
10 |
Correct |
8 ms |
7424 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
96 ms |
13816 KB |
Output is correct |
2 |
Correct |
83 ms |
11468 KB |
Output is correct |
3 |
Correct |
516 ms |
169848 KB |
Output is correct |
4 |
Correct |
151 ms |
27276 KB |
Output is correct |
5 |
Correct |
162 ms |
27352 KB |
Output is correct |
6 |
Correct |
380 ms |
117224 KB |
Output is correct |
7 |
Correct |
597 ms |
169764 KB |
Output is correct |
8 |
Correct |
540 ms |
170356 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
7424 KB |
Output is correct |
2 |
Correct |
8 ms |
7424 KB |
Output is correct |
3 |
Correct |
8 ms |
7424 KB |
Output is correct |
4 |
Correct |
8 ms |
7424 KB |
Output is correct |
5 |
Correct |
8 ms |
7424 KB |
Output is correct |
6 |
Correct |
8 ms |
7424 KB |
Output is correct |
7 |
Correct |
9 ms |
7424 KB |
Output is correct |
8 |
Correct |
8 ms |
7424 KB |
Output is correct |
9 |
Correct |
8 ms |
7424 KB |
Output is correct |
10 |
Correct |
8 ms |
7424 KB |
Output is correct |
11 |
Correct |
96 ms |
13816 KB |
Output is correct |
12 |
Correct |
83 ms |
11468 KB |
Output is correct |
13 |
Correct |
516 ms |
169848 KB |
Output is correct |
14 |
Correct |
151 ms |
27276 KB |
Output is correct |
15 |
Correct |
162 ms |
27352 KB |
Output is correct |
16 |
Correct |
380 ms |
117224 KB |
Output is correct |
17 |
Correct |
597 ms |
169764 KB |
Output is correct |
18 |
Correct |
540 ms |
170356 KB |
Output is correct |
19 |
Correct |
106 ms |
13736 KB |
Output is correct |
20 |
Correct |
92 ms |
11456 KB |
Output is correct |
21 |
Correct |
545 ms |
169764 KB |
Output is correct |
22 |
Correct |
181 ms |
27384 KB |
Output is correct |
23 |
Correct |
209 ms |
27460 KB |
Output is correct |
24 |
Correct |
383 ms |
117144 KB |
Output is correct |
25 |
Correct |
612 ms |
169720 KB |
Output is correct |
26 |
Correct |
542 ms |
170360 KB |
Output is correct |
27 |
Correct |
83 ms |
11384 KB |
Output is correct |
28 |
Correct |
132 ms |
16044 KB |
Output is correct |
29 |
Correct |
719 ms |
169848 KB |
Output is correct |
30 |
Correct |
522 ms |
90356 KB |
Output is correct |
31 |
Correct |
462 ms |
90320 KB |
Output is correct |
32 |
Correct |
681 ms |
169792 KB |
Output is correct |
33 |
Correct |
9 ms |
7424 KB |
Output is correct |
34 |
Correct |
9 ms |
7424 KB |
Output is correct |
35 |
Correct |
9 ms |
7396 KB |
Output is correct |
36 |
Correct |
11 ms |
7424 KB |
Output is correct |
37 |
Correct |
9 ms |
7396 KB |
Output is correct |
38 |
Correct |
10 ms |
7424 KB |
Output is correct |
39 |
Correct |
9 ms |
7552 KB |
Output is correct |
40 |
Correct |
11 ms |
7424 KB |
Output is correct |
41 |
Correct |
8 ms |
7424 KB |
Output is correct |
42 |
Correct |
9 ms |
7424 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
7424 KB |
Output is correct |
2 |
Incorrect |
43 ms |
8740 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |