제출 #68458

#제출 시각아이디문제언어결과실행 시간메모리
68458ekremBank (IZhO14_bank)C++98
71 / 100
1086 ms24252 KiB
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define N 1000005
using namespace std;

int n, m, ans, a[N], b[N], dp[2][N];
vector < int > g[N];

void dfs(int node, int top, int x, int yap){
	if(node > m){
		if(top == a[yap])
			g[yap].pb(x);
		return;
	}
	x *= 2;
	dfs(node + 1, top + b[node], x + 1, yap);
	dfs(node + 1, top, x, yap);
}

bool bul(int node, int bit){
	// cout << node << " -> " << bit << endl;
	if(node > n)
		return 1;
	for(int i = 0; i < g[node].size(); i++)
		if((bit&g[node][i]) == 0)
			if(bul(node + 1, (bit|g[node][i])))
				return 1;
	return 0;
}

int main(){
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%d %d",&n ,&m);
	for(int i = 1; i <= n; i++)
		scanf("%d",a + i);
	for(int i = 1; i <= m; i++)
		scanf("%d",b + i);
	for(int i = 1; i <= n; i++)
		dfs(1, 0, 0, i);
	// for(int i = 1; i <= n; i++,puts(""))
	// 	for(int j = 0; j < g[i].size(); j++)
	// 		printf("%d ",g[i][j]);
	if(bul(1, 0))
		printf("YES\n");
	else
		printf("NO\n");
	return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

bank.cpp: In function 'bool bul(int, int)':
bank.cpp:27:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < g[node].size(); i++)
                 ~~^~~~~~~~~~~~~~~~
bank.cpp: In function 'int main()':
bank.cpp:37:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&n ,&m);
  ~~~~~^~~~~~~~~~~~~~~~
bank.cpp:39:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",a + i);
   ~~~~~^~~~~~~~~~~~
bank.cpp:41:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",b + i);
   ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...