# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
317086 | 2020-10-29T02:55:03 Z | 8e7 | DEL13 (info1cup18_del13) | C++14 | 144 ms | 632 KB |
#include <iostream> #include <algorithm> #include <utility> #include <vector> #define ll long long #define pii pair<int, int> #define maxn 200005 using namespace std; bool dp[1<<18]; void build(int n) { dp[(1<<n) - 1] = true; for (int i = (1<<n) - 2;i >= 0;i--) { vector<int> pos; for (int j = 0;j < n;j++) { //cout << ((i & (1<<j)) ? 1 : 0); if ((i & (1<<j)) == 0) { pos.push_back(j); } } for (int j = 0;j < pos.size() - 1;j++) { int cnt = 0; for (int x = pos[j];x < n;x++) { cnt += ((i & (1<<x)) ? 1 : 0); if (cnt > 1) continue; if ((i & (1<<x)) == 0 && cnt == 1) { dp[i] |= dp[i + (1<<(pos[j])) + (1<<x)]; } } } //cout << " " << (dp[i] ? 1 : 0) << endl; } } int main() { ios_base::sync_with_stdio(0);cin.tie(0); int t; cin >> t; int cnt = 0; while (t--) { int n, q; cin >> n >> q; if (cnt == 0) { build(n); } int a = 0; for (int i = 0;i < q;i++) { int x; cin >> x; a += (1<<(x - 1)); } //cout << a << endl; if (dp[a]) { cout << 0 << endl; cout << endl; } else { cout << -1 << endl; } cnt++; } } /* 4 7 3 1 5 7 7 3 1 2 7 */
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is partially correct |
2 | Correct | 2 ms | 384 KB | Output is partially correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is partially correct |
2 | Correct | 2 ms | 384 KB | Output is partially correct |
3 | Correct | 74 ms | 504 KB | Output is partially correct |
4 | Correct | 144 ms | 632 KB | Output is partially correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 512 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Runtime error | 1 ms | 512 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is partially correct |
2 | Correct | 2 ms | 384 KB | Output is partially correct |
3 | Correct | 74 ms | 504 KB | Output is partially correct |
4 | Correct | 144 ms | 632 KB | Output is partially correct |
5 | Runtime error | 1 ms | 512 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
6 | Runtime error | 1 ms | 512 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
7 | Runtime error | 1 ms | 512 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is partially correct |
2 | Correct | 2 ms | 384 KB | Output is partially correct |
3 | Correct | 74 ms | 504 KB | Output is partially correct |
4 | Correct | 144 ms | 632 KB | Output is partially correct |
5 | Runtime error | 1 ms | 512 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
6 | Runtime error | 1 ms | 512 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
7 | Runtime error | 1 ms | 512 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
8 | Runtime error | 1 ms | 512 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
9 | Runtime error | 1 ms | 512 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
10 | Runtime error | 1 ms | 512 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
11 | Runtime error | 1 ms | 512 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |