제출 #854293

#제출 시각아이디문제언어결과실행 시간메모리
854293WebbWayne은행 (IZhO14_bank)C++14
100 / 100
194 ms3276 KiB
#include <iostream> #include <bits/stdc++.h> using namespace std; #define ll long long #define rep(i, a, b) for(int i = a; i < b; i++) #define vi vector<int> #define ii pair<int, int> #define pb push_back #define f first #define s second #define all(i) (i).begin(), (i).end() #define MOD 1000000007 #define endl '\n' int n, m; vector<vi> common; vector<vector<bool>> visited; void backtrack(int i, int state) { if(i == n) { cout<<"YES"<<endl; exit(0); } if(visited[i][state]) return; else visited[i][state] = true; rep(j, 0, common[i].size()) { int mask = common[i][j]; if(mask & state) continue; backtrack(i+1, state | mask); } // return; } int main() { cin.tie(NULL); ios_base::sync_with_stdio(NULL); cin>>n>>m; vi nums(n); vi bank(m); common.resize(n); visited.resize(n, vector<bool>(1<<m)); rep(i, 0, n) cin>>nums[i]; rep(i, 0, m) cin>>bank[i]; for(int mask = 0; mask < (1<<m); mask++) { int sum = 0; for(int i = 0; i < m; i++) if(mask & (1<<i)) sum += bank[i]; for(int i = 0; i < n; i++) if(sum == nums[i]) common[i].pb(mask); //this is a possible combination that could make my sum happen. } backtrack(0, 0); cout<<"NO"<<endl; return 0; }

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

bank.cpp: In function 'void backtrack(int, int)':
bank.cpp:7:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 | #define rep(i, a, b) for(int i = a; i < b; i++)
......
   30 |     rep(j, 0, common[i].size()) {
      |         ~~~~~~~~~~~~~~~~~~~~~~         
bank.cpp:30:5: note: in expansion of macro 'rep'
   30 |     rep(j, 0, common[i].size()) {
      |     ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...