답안 #869254

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
869254 2023-11-03T20:11:56 Z MinaRagy06 Present (RMI21_present) C++17
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;

const int N = 12;
vector<vector<int>> all;
bool check(vector<int> v) {
	bool ok[N + 1]{};
	for (auto i : v) ok[i] = 1;
	for (int i = 0; i < v.size(); i++) {
		for (int j = i + 1; j < v.size(); j++) {
			if (!ok[gcd(v[i], v[j])]) return 0;
		}
	}
	return 1;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	for (int msk = 0; msk < (1 << N); msk++) {
		vector<int> v;
		for (int j = N - 1; j >= 0; j--) {
			if ((msk >> j) & 1) v.push_back(j + 1);
		}
		if (check(v)) all.push_back(v);
	}
	sort(all.begin(), all.end());
	int t;
	cin >> t;
	while (t--) {
		int k;
		cin >> k;
		cout << all[k].size() << ' ';
		for (auto i : all[k]) {
			cout << i << ' ';
		}
		cout << '\n';
	}
	return 0;
}

Compilation message

Main.cpp: In function 'bool check(std::vector<int>)':
Main.cpp:10:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |  for (int i = 0; i < v.size(); i++) {
      |                  ~~^~~~~~~~~~
Main.cpp:11:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |   for (int j = i + 1; j < v.size(); j++) {
      |                       ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -