Submission #317241

# Submission time Handle Problem Language Result Execution time Memory
317241 2020-10-29T07:36:50 Z Seanliu DEL13 (info1cup18_del13) C++14
0 / 100
190 ms 131076 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

const int maxN = 17;
int T, N, M, l2[1 << maxN], fromst[1 << maxN], del[1 << maxN];
bool pos[1 << maxN];

void solve(){
	cin >> N >> M;
	vector<int> has, wok;
	has.resize(M);
	fill(pos, pos + (1 << N), false);
	for(int i = 0; i < M; i++){
		cin >> has[i];
		has[i]--;
	}
	queue<int> que;
	que.push((1 << N) - 1);
	pos[(1 << N) - 1] = true;
	int curst = 0;
	for(int x : has) curst ^= (1 << x);
	while(que.size()){
		int i = que.front();
		que.pop();
		vector<int>().swap(wok);	
		int x = i;
		while(x){
			wok.push_back(l2[(x & -x)]);
			x -= (x & -x);
		}
		//for(int x : wok) cout << x << " ";
		//cout << endl;

		if(wok.size() >= 3){
			for(int j = 1; j < wok.size() - 1; j++){
				int n = i ^ (1 << wok[j - 1]) ^ (1 << wok[j + 1]);
				if(pos[n] || ((n & curst) != curst)) continue;
				pos[n] = true;
				if(n == curst) break;
				que.push(n);
				fromst[n] = i;
				del[n] = wok[j];
			}
		}

	}
		//cout << "curst = " << curst << endl;
	if(!pos[curst]){
		cout << -1 << endl;
		return;
	}
	vector<int> ans;
	vector<int>().swap(ans);
	while(curst != ((1 << N) - 1)){
		ans.push_back(del[curst]);
		curst = fromst[curst];
	}
	reverse(ans.begin(), ans.end());
	cout << ans.size() << endl;
	for(int x : ans) cout << x + 1 << " ";
	cout << endl;
}

int main(){
	for(int i = 0; i < maxN; i++) l2[1 << i] = i;
	cin >> T;
	while(T--){
		solve();
	}
}

Compilation message

del13.cpp: In function 'void solve()':
del13.cpp:38:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |    for(int j = 1; j < wok.size() - 1; j++){
      |                   ~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 167 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Runtime error 190 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 167 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Runtime error 190 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Runtime error 158 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Runtime error 167 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 3840 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 5 ms 3840 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 167 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Runtime error 190 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Runtime error 158 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Runtime error 167 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
5 Runtime error 1 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 1 ms 544 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 5 ms 3840 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 167 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Runtime error 190 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Runtime error 158 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Runtime error 167 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
5 Runtime error 1 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 1 ms 544 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 5 ms 3840 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 5 ms 3840 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 5 ms 3840 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 2 ms 768 KB Execution killed with signal 11 (could be triggered by violating memory limits)