제출 #67137

#제출 시각아이디문제언어결과실행 시간메모리
67137cdemirerDEL13 (info1cup18_del13)C++17
12 / 100
7 ms920 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> ii; typedef vector<int> vi; typedef vector<ii> vii; typedef vector<vii> vvii; typedef vector<vi> vvi; typedef pair<double, double> dodo; #define pb(x) push_back(x) #define mp(x, y) make_pair(x, y) int N, M; bool dp[524288] = {0}; void func(int m) { if (dp[m]) return; dp[m] = true; if (m == (m & -m)) return; int t1 = m; int t2 = t1 - (t1 & -t1); while (true) { if (t2 == (t2 & -t2)) return; int x = m; x -= (t1 & -t1); int t3 = t2 - (t2 & -t2); x -= (t3 & -t3); func(x); t1 = t2; t2 = t3; } } void pp() { func((1<<N)-1); //for (int i = 0; i < 10; i++) cerr << dp[i] << " "; //cerr << endl; } int main(int argc, char **argv) { ios_base::sync_with_stdio(0); cin.tie(0); int TC; cin >> TC; for (int tc = 1; tc <= TC; tc++) { cin >> N >> M; if (tc == 1) pp(); int x = 0; for (int i = 0; i < M; i++) { int a; cin >> a; x += (1<<(a-1)); } if (dp[x]) { cout << "0\n\n"; } else { cout << "-1\n"; } } return 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...
#Verdict Execution timeMemoryGrader output
Fetching results...