제출 #1107275

#제출 시각아이디문제언어결과실행 시간메모리
1107275vjudge1은행 (IZhO14_bank)C++17
71 / 100
543 ms262144 KiB
#include <bits/stdc++.h> using namespace std; int n , T , q , m ; signed main(){ ios_base::sync_with_stdio(0) , cin.tie(0); cin>> n >> m ; int a[n+1] , b[m] , ok =0 ; for(int i= 1 ; i <= n ;i++)cin>> a[i]; for(int i =0 ; i < m; i++)cin>> b[i]; vector<vector<int>>mp[20000]; for(int j = 0 ; j < (1 << m )- 1; j++){ int x =0 ; vector<int>v; for(int u =0 ; u < m ; u++){ if((j >> u )&1){ x+=b[u]; v.push_back(b[u]); } } mp[x].push_back(v); } queue<pair<pair<int , unordered_map<int, int >>, map<vector<int> , int >>>q; unordered_map<int ,int >h; map<vector<int> , int >uss; for(int i =0 ; i < m ; i++){ h[b[i]]++; } q.push({{1 , h} , uss}); while(q.size()){ pair<pair<int , unordered_map<int , int >> , map<vector<int> , int >> p= q.front(); q.pop(); int v = p.first.first ; unordered_map<int ,int >us = p.first.second; map<vector<int> , int >usv = p.second; for(auto it:mp[a[v]]){ int ko =0 ; if(!usv[it]){ for(auto at:it){ if(us[at])ko++; us[at]--; } if(ko== it.size()){ if(v == n ){ cout << "YES"; return 0 ; } q.push({{v + 1 ,us} , usv}); } else { usv[it] = 1; } for(auto at:it){ us[at]++; } } } } cout << "NO"; }

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

bank.cpp: In function 'int main()':
bank.cpp:42:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |                 if(ko== it.size()){
      |                    ~~^~~~~~~~~~~~
bank.cpp:7:25: warning: unused variable 'ok' [-Wunused-variable]
    7 |     int a[n+1] , b[m] , ok =0 ;
      |                         ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...