Submission #197144

#TimeUsernameProblemLanguageResultExecution timeMemory
197144PankinDEL13 (info1cup18_del13)C++14
0 / 100
1058 ms131076 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> /* #pragma GCC optimize("unroll-loops") #pragma GCC optimize("Ofast") #pragma GCC optimize("-O3") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") */ #define mp make_pair #define ll long long #define ld long double #define pb push_back #define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define fs first.first #define sc first.second #define tr second #define getfiles ifstream cin("input.txt"); ofstream cout("output.txt"); #define endl '\n' #define pii pair<int, int> #define tri pair< pair<int, int>, int > #define mt(x, y, z) make_pair(make_pair(x, y), z) const int INF = 2000000005; const ll BIG_INF = 2000000000000000005; const int mod = 1000000007; const int P = 31; const ld PI = 3.141592653589793238462643; const double eps = 1e-9; using namespace std; using namespace __gnu_pbds; bool valid(int x, int y, int n, int m) { return x >= 0 && y >= 0 && x < n && y < m; } mt19937 rng(1999999973); typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; vector<int> p, ans; int n, q; int mask, cur_mask; bool brute() { if (mask == cur_mask) return true; vector<int> cur; for (int i = 0; i < n; i++) { if ((cur_mask>>i) % 2 == 1) cur.pb(i); } for (int i = 1; i < cur.size() - 1; i++) { cur_mask ^= (1 << cur[i - 1]); cur_mask ^= (1 << cur[i + 1]); ans.pb(cur[i] + 1); if (brute()) return true; cur_mask ^= (1 << cur[i - 1]); cur_mask ^= (1 << cur[i + 1]); ans.pop_back(); } return false; } signed main() { //fast_io; int tests; cin >> tests; while(tests--) { cin >> n >> q; p.clear(); p.resize(q); for (int i = 0; i < q; i++) { cin >> p[i]; p[i]--; mask |= (1 << p[i]); } cur_mask = (1 << n) - 1; if (!brute()) { cout << -1 << endl; } cout << ans.size() << endl; for (int i = 0; i < ans.size(); i++) cout << ans[i] << " "; if (ans.size() != 0) cout << endl; ans.clear(); mask = 0; } return 0; } /* 1 10 4 1 2 3 7 1110001000 */

Compilation message (stderr)

del13.cpp: In function 'bool brute()':
del13.cpp:59:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 1; i < cur.size() - 1; i++) {
                     ~~^~~~~~~~~~~~~~~~
del13.cpp: In function 'int main()':
del13.cpp:95:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = 0; i < ans.size(); i++)
                         ~~^~~~~~~~~~~~
#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...