Submission #524637

# Submission time Handle Problem Language Result Execution time Memory
524637 2022-02-09T17:35:19 Z maks007 Table Tennis (info1cup20_tabletennis) C++14
29 / 100
37 ms 3064 KB
#include <bits/stdc++.h>
 
using namespace std;
 #define break_it assert(false)
int main(void) {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	vector <int> a(n+k);
	for(int i = 0; i < n +k; i ++) cin >> a[i];
	function <int(vector <int>)> check=[](vector <int> s) {
		int n = s.size();
		for(int i = 0; i < n; i ++) {
			int j = i + 1;
			if(j >= n or n - i - 1 < 0 or n - j - 1 < 0) break;
			if(s[i] + s[n-i-1] == s[j]+s[n-j-1]) continue;
			return 0;
		}
		return 1;
	};
	function <void(int, int)> solve=[&](int start, int end) {
		vector <int> fors;
		
		int sum = a[start] + a[end];
		int none = -1;
		int l = 0, r = n+k-1;
		while(l < r){
			if(a[l] + a[r] > sum) {
				if(none != -1) return;
				none = r;
				r--;
			}else if(a[l] + a[r] < sum) {
				if(none != -1) return;
				none = l;
				l ++;
			}
			l ++;
			r --;
		}
		if(none == -1) {
			none = (n+k)/2;
		}
		for(int i = 0; i <= n+k-1; i ++) {
			if(none == i) continue;
			fors.push_back(a[i]);
		}
		for(auto i : fors) cout << i << " ";
		exit(0);
	};	
	function <void(int, int)> solve2=[&](int start, int end) {
		vector <int> fors;
		
		int sum = a[start] + a[end];
		int none = -1, none2 = -1;
		int l = 0, r = n+k-1;
		while(l < r){
			if(a[l] + a[r] > sum) {
				if(none != -1 and none2 != -1) return;
				if(none == -1) {
					none = r;	
				}else none2 = r;
				r--;
			}else if(a[l] + a[r] < sum) {
				if(none != -1 and none2 != -1) return;
				if(none == -1) {
					none = l;	
				}else none2 = l;
				l ++;
			}
			l ++;
			r --;
		}
		if(none == -1) {
			none = (n+k)/2;
		}
		for(int i = 0; i <= n+k-1; i ++) {
			if(none == i or i == none2) continue;
			fors.push_back(a[i]);
		}
		for(auto i : fors) cout << i << " ";
		exit(0);
	};	
	if(n+k<=18) {
		for(int mask = 0; mask < (1 << (n+k)); mask ++) {	
			if(__builtin_popcount(mask) == n) {
				vector <int> v;
				for(int i = 0; i < n+k; i ++) {
					if((mask & (1 << i))!=0) {
						v.push_back(a[i]);
					}
				}
				if(check(v)) {
					for(int i = 0; i < v.size(); i ++) cout << v[i] << " ";
					return false;
				}
			}
		}
		return false;
	}else if(k == 1){
		solve(0, n+k-1);
		solve(0, n+k-2);
		solve(1, n+k-1);
		break_it;
	}else if(k == 2) {

	}
	return false;
}  

Compilation message

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:94:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   94 |      for(int i = 0; i < v.size(); i ++) cout << v[i] << " ";
      |                     ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 716 KB Output is correct
2 Correct 27 ms 3056 KB Output is correct
3 Correct 26 ms 3028 KB Output is correct
4 Correct 37 ms 3064 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 844 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -