Submission #63196

# Submission time Handle Problem Language Result Execution time Memory
63196 2018-08-01T05:24:00 Z 정원준(#1835) Paths (BOI18_paths) C++11
73 / 100
3000 ms 96240 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 13 ms 7416 KB Output is correct
2 Correct 9 ms 7452 KB Output is correct
3 Correct 8 ms 7472 KB Output is correct
4 Correct 8 ms 7636 KB Output is correct
5 Correct 9 ms 7636 KB Output is correct
6 Correct 8 ms 7636 KB Output is correct
7 Correct 9 ms 7636 KB Output is correct
8 Correct 8 ms 7636 KB Output is correct
9 Correct 9 ms 7692 KB Output is correct
10 Correct 8 ms 7692 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 254 ms 16324 KB Output is correct
2 Correct 223 ms 16324 KB Output is correct
3 Correct 2612 ms 95816 KB Output is correct
4 Correct 307 ms 95816 KB Output is correct
5 Correct 194 ms 95816 KB Output is correct
6 Correct 1338 ms 95816 KB Output is correct
7 Correct 2470 ms 95816 KB Output is correct
8 Correct 2693 ms 96196 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 7416 KB Output is correct
2 Correct 9 ms 7452 KB Output is correct
3 Correct 8 ms 7472 KB Output is correct
4 Correct 8 ms 7636 KB Output is correct
5 Correct 9 ms 7636 KB Output is correct
6 Correct 8 ms 7636 KB Output is correct
7 Correct 9 ms 7636 KB Output is correct
8 Correct 8 ms 7636 KB Output is correct
9 Correct 9 ms 7692 KB Output is correct
10 Correct 8 ms 7692 KB Output is correct
11 Correct 254 ms 16324 KB Output is correct
12 Correct 223 ms 16324 KB Output is correct
13 Correct 2612 ms 95816 KB Output is correct
14 Correct 307 ms 95816 KB Output is correct
15 Correct 194 ms 95816 KB Output is correct
16 Correct 1338 ms 95816 KB Output is correct
17 Correct 2470 ms 95816 KB Output is correct
18 Correct 2693 ms 96196 KB Output is correct
19 Correct 218 ms 96196 KB Output is correct
20 Correct 171 ms 96196 KB Output is correct
21 Correct 2694 ms 96196 KB Output is correct
22 Correct 372 ms 96196 KB Output is correct
23 Correct 190 ms 96196 KB Output is correct
24 Correct 1166 ms 96196 KB Output is correct
25 Correct 2285 ms 96196 KB Output is correct
26 Correct 2817 ms 96240 KB Output is correct
27 Correct 296 ms 96240 KB Output is correct
28 Correct 369 ms 96240 KB Output is correct
29 Execution timed out 3030 ms 96240 KB Time limit exceeded
30 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 96240 KB Output is correct
2 Correct 74 ms 96240 KB Output is correct
3 Correct 66 ms 96240 KB Output is correct
4 Correct 575 ms 96240 KB Output is correct
5 Correct 186 ms 96240 KB Output is correct
6 Correct 469 ms 96240 KB Output is correct
7 Correct 68 ms 96240 KB Output is correct
8 Correct 527 ms 96240 KB Output is correct
9 Correct 280 ms 96240 KB Output is correct
10 Correct 385 ms 96240 KB Output is correct
11 Correct 321 ms 96240 KB Output is correct
12 Correct 316 ms 96240 KB Output is correct
13 Correct 219 ms 96240 KB Output is correct
14 Correct 454 ms 96240 KB Output is correct
15 Correct 580 ms 96240 KB Output is correct
16 Correct 10 ms 96240 KB Output is correct
17 Correct 10 ms 96240 KB Output is correct
18 Correct 10 ms 96240 KB Output is correct
19 Correct 10 ms 96240 KB Output is correct
20 Correct 8 ms 96240 KB Output is correct
21 Correct 10 ms 96240 KB Output is correct
22 Correct 10 ms 96240 KB Output is correct
23 Correct 10 ms 96240 KB Output is correct
24 Correct 10 ms 96240 KB Output is correct
25 Correct 8 ms 96240 KB Output is correct