#pragma GCC optimize("Ofast,unroll-loops")
#include<bits/stdc++.h>
#define int long long
//#define ll long long
#define down cout<<'\n';
#define debug cout<<" cucuucucuuu",down
#define NHP ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
#define modwwe int t;cin>>t; while(t--)
#define bit(i,j) (i>>j&1)
#define sobit(a) __builtin_popcountll(a)
#define task "test"
#define fin(x) freopen(x".inp","r",stdin)
#define fou(x) freopen(x".ans","w",stdout)
#define pb push_back
#define checktime cerr << (double)clock() / CLOCKS_PER_SEC * 1000 << " ms";
using namespace std;
#define getchar_unlocked getchar
inline int scan()
{
char c = getchar_unlocked();
int x = 0;
while(c<'0'||c>'9')
{
c=getchar_unlocked();
}
while(c>='0'&&c<='9')
{
x=(x<<1)+(x<<3)+c-'0';
c=getchar_unlocked();
}
return x;
}
void phongbeo();
const int inf=1e9;
const int mod2=998244353;
const int mod1=998244353;
struct icd
{
long double a;
int b;
};
struct ib
{
int a;
int b;
};
struct ic
{
int a,b,c;
};
struct id
{
int a,b,c,d;
};
struct ie
{
int a,b,c,d,e;
};
int n,m,s1,s2,s4,s3,sf,k,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,dem=0,s33,dem3,dem4,l,r,mid,l2,r2;
int i,s10,s12;
int kk;
int el=29;
main()
{
#ifndef ONLINE_JUDGE
// fin(task);
//fou(task);
#endif
NHP
/// cin>>s1;
//modwwe
phongbeo();
//checktime
}
int dp[300001][32];
int a[300001];
vector<int> v[300001];
void phongbeo()
{
cin>>n>>m>>k;
for(int i=1;i<=n;i++)
cin>>a[i],a[i]--,dp[i][(1<<a[i])]=1;
for(int i=1;i<=m;i++)
cin>>l>>r,v[l].pb(r),v[r].pb(l);
for(int j=1;j<(1<<k);j++)
for(int i=1;i<=n;i++){
if(dp[i][j]==0) continue;
for(auto k:v[i])
if(!bit(j,a[k])){
dp[k][j+(1<<a[k])]+=dp[i][j];
}
s4+=dp[i][j];
}
cout<<s4-n;
}
Compilation message
paths.cpp:67:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
67 | main()
| ^~~~
paths.cpp: In function 'void phongbeo()':
paths.cpp:87:3: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
87 | for(int i=1;i<=m;i++)
| ^~~
paths.cpp:89:6: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
89 | for(int j=1;j<(1<<k);j++)
| ^~~
paths.cpp:92:10: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
92 | for(auto k:v[i])
| ^~~
paths.cpp:96:14: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
96 | s4+=dp[i][j];
| ^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
10844 KB |
Output is correct |
2 |
Correct |
2 ms |
10844 KB |
Output is correct |
3 |
Correct |
2 ms |
10844 KB |
Output is correct |
4 |
Correct |
3 ms |
10844 KB |
Output is correct |
5 |
Correct |
2 ms |
10844 KB |
Output is correct |
6 |
Correct |
2 ms |
10844 KB |
Output is correct |
7 |
Correct |
3 ms |
10844 KB |
Output is correct |
8 |
Correct |
2 ms |
10844 KB |
Output is correct |
9 |
Correct |
3 ms |
10844 KB |
Output is correct |
10 |
Correct |
2 ms |
10844 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
48 ms |
22872 KB |
Output is correct |
2 |
Correct |
44 ms |
20060 KB |
Output is correct |
3 |
Correct |
178 ms |
99924 KB |
Output is correct |
4 |
Correct |
63 ms |
28756 KB |
Output is correct |
5 |
Correct |
59 ms |
28752 KB |
Output is correct |
6 |
Correct |
121 ms |
72900 KB |
Output is correct |
7 |
Correct |
160 ms |
99924 KB |
Output is correct |
8 |
Correct |
141 ms |
100500 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
10844 KB |
Output is correct |
2 |
Correct |
2 ms |
10844 KB |
Output is correct |
3 |
Correct |
2 ms |
10844 KB |
Output is correct |
4 |
Correct |
3 ms |
10844 KB |
Output is correct |
5 |
Correct |
2 ms |
10844 KB |
Output is correct |
6 |
Correct |
2 ms |
10844 KB |
Output is correct |
7 |
Correct |
3 ms |
10844 KB |
Output is correct |
8 |
Correct |
2 ms |
10844 KB |
Output is correct |
9 |
Correct |
3 ms |
10844 KB |
Output is correct |
10 |
Correct |
2 ms |
10844 KB |
Output is correct |
11 |
Correct |
48 ms |
22872 KB |
Output is correct |
12 |
Correct |
44 ms |
20060 KB |
Output is correct |
13 |
Correct |
178 ms |
99924 KB |
Output is correct |
14 |
Correct |
63 ms |
28756 KB |
Output is correct |
15 |
Correct |
59 ms |
28752 KB |
Output is correct |
16 |
Correct |
121 ms |
72900 KB |
Output is correct |
17 |
Correct |
160 ms |
99924 KB |
Output is correct |
18 |
Correct |
141 ms |
100500 KB |
Output is correct |
19 |
Correct |
47 ms |
22864 KB |
Output is correct |
20 |
Correct |
37 ms |
20312 KB |
Output is correct |
21 |
Correct |
144 ms |
99920 KB |
Output is correct |
22 |
Correct |
61 ms |
28756 KB |
Output is correct |
23 |
Correct |
58 ms |
28756 KB |
Output is correct |
24 |
Correct |
114 ms |
72892 KB |
Output is correct |
25 |
Correct |
164 ms |
99924 KB |
Output is correct |
26 |
Correct |
159 ms |
100396 KB |
Output is correct |
27 |
Correct |
48 ms |
20056 KB |
Output is correct |
28 |
Correct |
69 ms |
24320 KB |
Output is correct |
29 |
Correct |
209 ms |
99920 KB |
Output is correct |
30 |
Correct |
134 ms |
60096 KB |
Output is correct |
31 |
Correct |
146 ms |
60100 KB |
Output is correct |
32 |
Correct |
197 ms |
99936 KB |
Output is correct |
33 |
Correct |
2 ms |
10840 KB |
Output is correct |
34 |
Correct |
2 ms |
10844 KB |
Output is correct |
35 |
Correct |
2 ms |
10840 KB |
Output is correct |
36 |
Correct |
3 ms |
10844 KB |
Output is correct |
37 |
Correct |
3 ms |
10844 KB |
Output is correct |
38 |
Correct |
2 ms |
10844 KB |
Output is correct |
39 |
Correct |
2 ms |
10904 KB |
Output is correct |
40 |
Correct |
2 ms |
10844 KB |
Output is correct |
41 |
Correct |
2 ms |
10844 KB |
Output is correct |
42 |
Correct |
2 ms |
10844 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
10840 KB |
Output is correct |
2 |
Correct |
24 ms |
13660 KB |
Output is correct |
3 |
Correct |
15 ms |
13660 KB |
Output is correct |
4 |
Correct |
59 ms |
39520 KB |
Output is correct |
5 |
Correct |
43 ms |
40144 KB |
Output is correct |
6 |
Correct |
69 ms |
39508 KB |
Output is correct |
7 |
Correct |
21 ms |
13656 KB |
Output is correct |
8 |
Correct |
48 ms |
39516 KB |
Output is correct |
9 |
Correct |
42 ms |
40068 KB |
Output is correct |
10 |
Correct |
52 ms |
40136 KB |
Output is correct |
11 |
Correct |
44 ms |
26156 KB |
Output is correct |
12 |
Correct |
40 ms |
33100 KB |
Output is correct |
13 |
Correct |
40 ms |
26372 KB |
Output is correct |
14 |
Correct |
66 ms |
39772 KB |
Output is correct |
15 |
Correct |
55 ms |
39836 KB |
Output is correct |
16 |
Correct |
3 ms |
11104 KB |
Output is correct |
17 |
Correct |
2 ms |
10844 KB |
Output is correct |
18 |
Correct |
2 ms |
10844 KB |
Output is correct |
19 |
Correct |
2 ms |
10844 KB |
Output is correct |
20 |
Correct |
2 ms |
10856 KB |
Output is correct |
21 |
Correct |
2 ms |
10840 KB |
Output is correct |
22 |
Correct |
3 ms |
10844 KB |
Output is correct |
23 |
Correct |
2 ms |
10844 KB |
Output is correct |
24 |
Correct |
2 ms |
10844 KB |
Output is correct |
25 |
Correct |
2 ms |
10844 KB |
Output is correct |