| ps | |
|---|---|
| 링크 | acmicpc.net/… |
| 출처 | BOJ |
| 문제 번호 | 23116 |
| 문제명 | AND |
| 레벨 | 골드 1 |
| 분류 |
애드혹 |
| 시간복잡도 | O(∑n) |
| 인풋사이즈 | ∑n<=10^5 |
| 사용한 언어 | Python 3.11 |
| 제출기록 | 43244KB / 324ms |
| 최고기록 | 324ms |
| 해결날짜 | 2023/08/22 |
"""Solution code for "BOJ 23116. AND".
- Problem link: https://www.acmicpc.net/problem/23116
- Solution link: http://www.teferi.net/ps/problems/boj/23116
Tags: [ad hoc]
"""
import sys
import functools
import operator
def main():
t = int(sys.stdin.readline())
for _ in range(t):
n = int(sys.stdin.readline())
b = [int(x) for x in sys.stdin.readline().split()]
andsum = functools.reduce(operator.and_, b)
if andsum not in b:
print('-1')
else:
answer = [andsum] * (n * 2)
answer[::2] = b
print(len(answer))
print(*answer)
if __name__ == '__main__':
main()