Submission #869255

# Submission time Handle Problem Language Result Execution time Memory
869255 2023-11-03T20:13:00 Z MinaRagy06 Present (RMI21_present) C++17
8 / 100
2 ms 604 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 (int j = all[k].size() - 1; j >= 0; j--) {
			cout << all[k][j] << ' ';
		}
		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++) {
      |                       ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 548 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 548 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Runtime error 2 ms 604 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 548 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Runtime error 2 ms 604 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 548 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Runtime error 2 ms 604 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 548 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Runtime error 2 ms 604 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -