제출 #1166483

#제출 시각아이디문제언어결과실행 시간메모리
1166483omar1312은행 (IZhO14_bank)C++20
71 / 100
72 ms8776 KiB
#pragma GCC optimize("O3,Ofast") #include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define all(x) x.begin(), x.end() const int mod = 1000000007; const int N = 200005; #define int unsigned short #define ll unsigned short ll a[N+2], b[N+2], dp[N+2], f[N+2], nes[N+2]; vector<int> masks[N+2]; bool ok = 0; int n, m; void dfs(int mask, int idx){ if(idx == n){ ok = 1; return; } if(ok)return; for(auto &i : masks[a[idx]]){ if(!(mask & i)){ if(ok)return; dfs(mask | i, idx + 1); } } } void solve(){ cin>>n>>m; for(int i = 0; i < n; i++){ cin>>a[i]; f[a[i]]++; nes[a[i]] = USHRT_MAX; } for(int i = 0; i < m; i++){ cin>>b[i]; } for(long long i = 1; i <= (1 << m); i++){ int sum = 0; for(int j = 0; j < m; j++){ if((i >> j) & 1)sum += b[j]; } masks[sum].pb(i); nes[sum] &= i; } for(int i = 0; i < n; i++){ for(int j = i + 1; j < n; j++){ if(b[i] == b[j])continue; if(nes[i] & nes[j]){ cout<<"NO"; return; } } } for(int i = 1; i <= 20000; i++){ if(f[i] > masks[i].size()){ cout<<"NO"; return; } } dfs(0, 0); cout<<(ok ? "YES" : "NO"); } signed main(){ cin.tie(0)->sync_with_stdio(0); int tt = 1; //cin>>tt; while(tt--){ solve(); cout<<'\n'; } }

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

bank.cpp:10: warning: "ll" redefined
   10 | #define ll unsigned short
      | 
bank.cpp:4: note: this is the location of the previous definition
    4 | #define ll long long
      |
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...