Submission #63195

# Submission time Handle Problem Language Result Execution time Memory
63195 2018-08-01T05:17:52 Z 정원준(#1835) Paths (BOI18_paths) C++11
73 / 100
3000 ms 98692 KB
#include <bits/stdc++.h>
#define L long long

using namespace std;

L n,m,kk,ans;
L dp[300030][32];
L col[300030];
vector<L>bit[6];
vector<L>v[300030];

L bits(L x){
	L ret=0;
	while(x)
	{
		ret+=x%2;
		x/=2;
	}
	return ret;
}


int main()
{
	scanf("%lld %lld %lld",&n,&m,&kk);
	L i,bi,binum,j,k;
	for(i=1;i<32;i++)
	{
		bit[bits(i)].push_back(i);
	}
	for(i=1;i<=n;i++)
	{
		scanf("%lld",&col[i]);
		col[i]--;
	}
	for(i=1;i<=m;i++)
	{
		L s,e;
		scanf("%lld %lld",&s,&e);
		v[s].push_back(e);
		v[e].push_back(s);
	}
	for(i=1;i<=n;i++)
	{
		dp[i][(1<<col[i])]=1;
		ans--;
	}
	for(i=1;i<=kk;i++)
	{
		//printf("%lld\n",i);
		for(binum=0;binum<bit[i].size();binum++)
		{
			bi=bit[i][binum];
			//printf("%lld ",bi);
			for(j=1;j<=n;j++)
			{
				ans+=dp[j][bi];
				if(i==kk) continue;
				for(k=0;k<v[j].size();k++)
				{
					if(!(bi&(1<<col[v[j][k]])))
					{
						dp[v[j][k]][bi|(1<<col[v[j][k]])]+=dp[j][bi];
					}
				}
			}
		}
		//puts("");
	}
	/*for(i=0;i<32;i++)
	{
		for(j=1;j<=n;j++)
		{
			printf("%lld ",dp[j][i]);
		}
		puts("");
	}*/
	printf("%lld",ans);
}

Compilation message

paths.cpp: In function 'int main()':
paths.cpp:51:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(binum=0;binum<bit[i].size();binum++)
               ~~~~~^~~~~~~~~~~~~~
paths.cpp:59:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(k=0;k<v[j].size();k++)
             ~^~~~~~~~~~~~
paths.cpp:25:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld %lld %lld",&n,&m,&kk);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
paths.cpp:33:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld",&col[i]);
   ~~~~~^~~~~~~~~~~~~~~~
paths.cpp:39:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld %lld",&s,&e);
   ~~~~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 9 ms 7416 KB Output is correct
2 Correct 11 ms 7416 KB Output is correct
3 Correct 9 ms 7472 KB Output is correct
4 Correct 8 ms 7472 KB Output is correct
5 Correct 9 ms 7508 KB Output is correct
6 Correct 8 ms 7584 KB Output is correct
7 Correct 9 ms 7584 KB Output is correct
8 Correct 10 ms 7660 KB Output is correct
9 Correct 11 ms 7660 KB Output is correct
10 Correct 10 ms 7660 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 256 ms 16144 KB Output is correct
2 Correct 191 ms 16144 KB Output is correct
3 Correct 2659 ms 95696 KB Output is correct
4 Correct 367 ms 95696 KB Output is correct
5 Correct 243 ms 95696 KB Output is correct
6 Correct 1390 ms 95696 KB Output is correct
7 Correct 2740 ms 95844 KB Output is correct
8 Correct 2709 ms 96460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 7416 KB Output is correct
2 Correct 11 ms 7416 KB Output is correct
3 Correct 9 ms 7472 KB Output is correct
4 Correct 8 ms 7472 KB Output is correct
5 Correct 9 ms 7508 KB Output is correct
6 Correct 8 ms 7584 KB Output is correct
7 Correct 9 ms 7584 KB Output is correct
8 Correct 10 ms 7660 KB Output is correct
9 Correct 11 ms 7660 KB Output is correct
10 Correct 10 ms 7660 KB Output is correct
11 Correct 256 ms 16144 KB Output is correct
12 Correct 191 ms 16144 KB Output is correct
13 Correct 2659 ms 95696 KB Output is correct
14 Correct 367 ms 95696 KB Output is correct
15 Correct 243 ms 95696 KB Output is correct
16 Correct 1390 ms 95696 KB Output is correct
17 Correct 2740 ms 95844 KB Output is correct
18 Correct 2709 ms 96460 KB Output is correct
19 Correct 241 ms 96460 KB Output is correct
20 Correct 261 ms 96460 KB Output is correct
21 Correct 2764 ms 96460 KB Output is correct
22 Correct 362 ms 96460 KB Output is correct
23 Correct 259 ms 96460 KB Output is correct
24 Correct 1380 ms 96460 KB Output is correct
25 Correct 2302 ms 97800 KB Output is correct
26 Correct 2833 ms 98692 KB Output is correct
27 Correct 229 ms 98692 KB Output is correct
28 Correct 420 ms 98692 KB Output is correct
29 Execution timed out 3061 ms 98692 KB Time limit exceeded
30 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 98692 KB Output is correct
2 Correct 73 ms 98692 KB Output is correct
3 Correct 51 ms 98692 KB Output is correct
4 Correct 502 ms 98692 KB Output is correct
5 Correct 267 ms 98692 KB Output is correct
6 Correct 642 ms 98692 KB Output is correct
7 Correct 87 ms 98692 KB Output is correct
8 Correct 626 ms 98692 KB Output is correct
9 Correct 348 ms 98692 KB Output is correct
10 Correct 468 ms 98692 KB Output is correct
11 Correct 337 ms 98692 KB Output is correct
12 Correct 314 ms 98692 KB Output is correct
13 Correct 327 ms 98692 KB Output is correct
14 Correct 630 ms 98692 KB Output is correct
15 Correct 554 ms 98692 KB Output is correct
16 Correct 10 ms 98692 KB Output is correct
17 Correct 9 ms 98692 KB Output is correct
18 Correct 10 ms 98692 KB Output is correct
19 Correct 10 ms 98692 KB Output is correct
20 Correct 11 ms 98692 KB Output is correct
21 Correct 11 ms 98692 KB Output is correct
22 Correct 10 ms 98692 KB Output is correct
23 Correct 9 ms 98692 KB Output is correct
24 Correct 11 ms 98692 KB Output is correct
25 Correct 8 ms 98692 KB Output is correct