Submission #63193

# Submission time Handle Problem Language Result Execution time Memory
63193 2018-08-01T05:16:25 Z 정원준(#1835) Paths (BOI18_paths) C++11
53 / 100
3000 ms 95744 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];
				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:58: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 8 ms 7416 KB Output is correct
3 Correct 8 ms 7604 KB Output is correct
4 Correct 8 ms 7604 KB Output is correct
5 Correct 7 ms 7604 KB Output is correct
6 Correct 8 ms 7604 KB Output is correct
7 Correct 11 ms 7604 KB Output is correct
8 Correct 9 ms 7748 KB Output is correct
9 Correct 11 ms 7748 KB Output is correct
10 Correct 11 ms 7748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 280 ms 16108 KB Output is correct
2 Correct 194 ms 16108 KB Output is correct
3 Execution timed out 3023 ms 95744 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 7416 KB Output is correct
2 Correct 8 ms 7416 KB Output is correct
3 Correct 8 ms 7604 KB Output is correct
4 Correct 8 ms 7604 KB Output is correct
5 Correct 7 ms 7604 KB Output is correct
6 Correct 8 ms 7604 KB Output is correct
7 Correct 11 ms 7604 KB Output is correct
8 Correct 9 ms 7748 KB Output is correct
9 Correct 11 ms 7748 KB Output is correct
10 Correct 11 ms 7748 KB Output is correct
11 Correct 280 ms 16108 KB Output is correct
12 Correct 194 ms 16108 KB Output is correct
13 Execution timed out 3023 ms 95744 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 95744 KB Output is correct
2 Correct 85 ms 95744 KB Output is correct
3 Correct 90 ms 95744 KB Output is correct
4 Correct 634 ms 95744 KB Output is correct
5 Correct 316 ms 95744 KB Output is correct
6 Correct 682 ms 95744 KB Output is correct
7 Correct 74 ms 95744 KB Output is correct
8 Correct 589 ms 95744 KB Output is correct
9 Correct 380 ms 95744 KB Output is correct
10 Correct 383 ms 95744 KB Output is correct
11 Correct 289 ms 95744 KB Output is correct
12 Correct 312 ms 95744 KB Output is correct
13 Correct 366 ms 95744 KB Output is correct
14 Correct 664 ms 95744 KB Output is correct
15 Correct 712 ms 95744 KB Output is correct
16 Correct 9 ms 95744 KB Output is correct
17 Correct 9 ms 95744 KB Output is correct
18 Correct 9 ms 95744 KB Output is correct
19 Correct 10 ms 95744 KB Output is correct
20 Correct 8 ms 95744 KB Output is correct
21 Correct 8 ms 95744 KB Output is correct
22 Correct 8 ms 95744 KB Output is correct
23 Correct 10 ms 95744 KB Output is correct
24 Correct 8 ms 95744 KB Output is correct
25 Correct 10 ms 95744 KB Output is correct