제출 #671750

#제출 시각아이디문제언어결과실행 시간메모리
671750smartmonky은행 (IZhO14_bank)C++14
71 / 100
73 ms5196 KiB
#include <bits/stdc++.h>
  
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
 
using namespace std;
const int N = 1e5;
vector <int> g[N];
int n, vis[25][N];
void rec(int pos, int v){
	if(pos == n + 1){
		cout <<"YES";
		exit(0);
	}
	vis[pos][v] = 1;
	for(auto to : g[pos]){
		if((v & to) == 0 && !vis[pos + 1][(v ^ to)])
			rec(pos + 1, (v ^ to));
	}
}
main(){
	int m;
	cin >> n >> m;
	vector <int> v(n + 1), a(m + 1);
	for(int i = 1; i <= n; i++){
		cin >> v[i];
	}	
	for(int i = 1; i <= m; i++){
		cin >> a[i];
	}
	for(int i = 1; i < (1 << m); i++){
		int sum = 0;
		for(int j = 0; j < m; j++)
		if(i & (1 << j)){
			sum += a[j + 1];
		}
		//cout << sum << endl;
		for(int j = 1; j <= n; j++){
			if(v[j] == sum)g[j].pb(i);
		}
	}
	rec(1, 0);
	cout << "NO";
}

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

bank.cpp:24:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   24 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...