Submission #146324

# Submission time Handle Problem Language Result Execution time Memory
146324 2019-08-23T13:27:58 Z MvC Paths (BOI18_paths) C++11
100 / 100
467 ms 57992 KB
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include<bits/stdc++.h>
//#include "boxes.h"
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=3e5+50;
const int mod=1e9+7;
using namespace std;
int n,m,k,i,j,t,x,y,c[nmax];
ll f[50][nmax],rs;
vector<int>a[nmax],vc[7];
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n>>m>>k;
	for(i=1;i<=n;i++)
	{
		cin>>c[i];
		c[i]--;
		vc[c[i]].pb(i);
	}
	while(m--)
	{
		cin>>x>>y;
		a[x].pb(y);
		a[y].pb(x);
	}
	for(i=0;i<k;i++)
	{
		for(j=0;j<vc[i].size();j++)
		{
			x=vc[i][j];
			f[1<<i][x]=1;
		}
	}
	for(i=0;i<(1<<k);i++)
	{
		for(j=1;j<=n;j++)
		{
			if(!f[i][j])continue;
			for(t=0;t<a[j].size();t++)
			{
				x=a[j][t];
				if(i&(1<<c[x]))continue;
				f[i|(1<<c[x])][x]+=f[i][j];
			}
			rs+=f[i][j];
		}
	}
	cout<<rs-n<<endl;
	return 0;
}

Compilation message

paths.cpp:2:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization("O3")
 
paths.cpp:3:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization("unroll-loops")
 
paths.cpp: In function 'int main()':
paths.cpp:46:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(j=0;j<vc[i].size();j++)
           ~^~~~~~~~~~~~~
paths.cpp:57:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(t=0;t<a[j].size();t++)
            ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 9 ms 7544 KB Output is correct
2 Correct 9 ms 7544 KB Output is correct
3 Correct 9 ms 7544 KB Output is correct
4 Correct 9 ms 7416 KB Output is correct
5 Correct 9 ms 7416 KB Output is correct
6 Correct 9 ms 7544 KB Output is correct
7 Correct 9 ms 7544 KB Output is correct
8 Correct 9 ms 7544 KB Output is correct
9 Correct 9 ms 7416 KB Output is correct
10 Correct 9 ms 7416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 106 ms 14200 KB Output is correct
2 Correct 84 ms 13304 KB Output is correct
3 Correct 386 ms 39016 KB Output is correct
4 Correct 152 ms 16228 KB Output is correct
5 Correct 141 ms 15744 KB Output is correct
6 Correct 277 ms 31208 KB Output is correct
7 Correct 431 ms 39068 KB Output is correct
8 Correct 369 ms 39688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 7544 KB Output is correct
2 Correct 9 ms 7544 KB Output is correct
3 Correct 9 ms 7544 KB Output is correct
4 Correct 9 ms 7416 KB Output is correct
5 Correct 9 ms 7416 KB Output is correct
6 Correct 9 ms 7544 KB Output is correct
7 Correct 9 ms 7544 KB Output is correct
8 Correct 9 ms 7544 KB Output is correct
9 Correct 9 ms 7416 KB Output is correct
10 Correct 9 ms 7416 KB Output is correct
11 Correct 106 ms 14200 KB Output is correct
12 Correct 84 ms 13304 KB Output is correct
13 Correct 386 ms 39016 KB Output is correct
14 Correct 152 ms 16228 KB Output is correct
15 Correct 141 ms 15744 KB Output is correct
16 Correct 277 ms 31208 KB Output is correct
17 Correct 431 ms 39068 KB Output is correct
18 Correct 369 ms 39688 KB Output is correct
19 Correct 108 ms 14260 KB Output is correct
20 Correct 87 ms 13356 KB Output is correct
21 Correct 379 ms 39140 KB Output is correct
22 Correct 140 ms 16120 KB Output is correct
23 Correct 129 ms 15608 KB Output is correct
24 Correct 268 ms 31132 KB Output is correct
25 Correct 407 ms 39092 KB Output is correct
26 Correct 380 ms 39780 KB Output is correct
27 Correct 104 ms 13432 KB Output is correct
28 Correct 146 ms 15880 KB Output is correct
29 Correct 444 ms 57992 KB Output is correct
30 Correct 319 ms 36144 KB Output is correct
31 Correct 328 ms 33900 KB Output is correct
32 Correct 467 ms 57892 KB Output is correct
33 Correct 9 ms 7548 KB Output is correct
34 Correct 9 ms 7544 KB Output is correct
35 Correct 9 ms 7544 KB Output is correct
36 Correct 9 ms 7416 KB Output is correct
37 Correct 9 ms 7416 KB Output is correct
38 Correct 9 ms 7544 KB Output is correct
39 Correct 9 ms 7544 KB Output is correct
40 Correct 9 ms 7544 KB Output is correct
41 Correct 9 ms 7416 KB Output is correct
42 Correct 9 ms 7416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 7544 KB Output is correct
2 Correct 55 ms 9564 KB Output is correct
3 Correct 35 ms 9228 KB Output is correct
4 Correct 95 ms 17780 KB Output is correct
5 Correct 81 ms 17772 KB Output is correct
6 Correct 153 ms 36992 KB Output is correct
7 Correct 40 ms 9336 KB Output is correct
8 Correct 121 ms 24312 KB Output is correct
9 Correct 91 ms 20976 KB Output is correct
10 Correct 101 ms 20072 KB Output is correct
11 Correct 98 ms 23156 KB Output is correct
12 Correct 96 ms 19288 KB Output is correct
13 Correct 98 ms 19712 KB Output is correct
14 Correct 158 ms 37020 KB Output is correct
15 Correct 135 ms 36976 KB Output is correct
16 Correct 9 ms 7544 KB Output is correct
17 Correct 9 ms 7544 KB Output is correct
18 Correct 9 ms 7388 KB Output is correct
19 Correct 9 ms 7416 KB Output is correct
20 Correct 9 ms 7416 KB Output is correct
21 Correct 9 ms 7544 KB Output is correct
22 Correct 9 ms 7544 KB Output is correct
23 Correct 9 ms 7544 KB Output is correct
24 Correct 9 ms 7544 KB Output is correct
25 Correct 9 ms 7416 KB Output is correct