| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1107538 | vjudge1 | 은행 (IZhO14_bank) | C++17 | 70 ms | 15432 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define speed ios_base::sync_with_stdio(0), cin.tie(0)
#define int long long
#define st first
#define nd second
#define pb push_back
#define love our_kolhoz
using namespace std;
const int N = 1e5 + 10, inf = 1e18, mod = 1e9 + 7;
//koz qorqaq
int n, m;
vector<int> g[N];
int a[N];
bool kek(int mask, int i) {
if (i == n - 1) {
for (auto to : g[a[i]]) {
if ((mask & (to)) == 0) {
return 1;
}
}
return 0;
}
for (auto to : g[a[i]]) {
if ((mask & (to)) == 0) {
kek((mask & (to)), i + 1);
}
}
return 0;
}
void solve() {
cin >> n >> m;
int b[m];
for (int i = 0; i < n; i++)
cin >> a[i];
for (int i = 0; i < m; i++)
cin >> b[i];
for (int i = 0; i < (1 << m); i++) {
int lol = 0;
for (int j = 0; j < m; j++) {
if (i & (1 << j)) {
lol += b[j];
}
}
//cout << lol << ' ' << i << ' ' << '\n';
g[lol].pb(i);
}
/*for (int i = 0; i < n; i++) {
cout << a[i] << ':';
for (int j = 0; j < g[a[i]].size(); j++) {
cout << g[a[i]][j] << ' ';
}
cout << '\n';
}*/
if (n == 1) {
cout << (g[a[0]].size() > 0 ? "YES\n" : "NO\n");
return;
}
for (int i = 0; i < g[a[0]].size(); i++) {
if (kek(g[a[0]][i], 1)) {
cout << "YES\n";
return;
}
}
cout << "NO\n";
}
signed main() {
speed;
//freopen("points.in ", "r", stdin);
//freopen("points.out", "w", stdout);
int _t = 1;
//cin >> _t;
while (_t--)
solve();
return 0;
}
// sau bol
// there's really no way of winning
// if in their eyes you'll always be a dumb blonde...
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
