Submission #737037

# Submission time Handle Problem Language Result Execution time Memory
737037 2023-05-06T13:43:28 Z mjhmjh1104 Present (RMI21_present) C++17
0 / 100
4000 ms 55924 KB
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")

#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int gcd(int x, int y) {
    return x % y ? gcd(y, x % y) : y;
}

bool validate(const vector<int> &v) {
    for (auto &i: v) for (auto &j: v) {
        int k = gcd(i, j);
        if (find(v.begin(), v.end(), k) == v.end()) return false;
    }
    return true;
}

int t, k;
vector<vector<int>> lt;

int main() {
    for (int i = 0; i < 1 << 25; i++) {
        vector<int> curr;
        for (int j = 24; j >= 0; j--) if (i & 1 << j) curr.push_back(j + 1);
        if (!validate(curr)) continue;
        lt.push_back(curr);
    }
    printf("%d\n", (int)lt.size());
    sort(lt.begin(), lt.end());
    for (scanf("%d", &t); t--; ) {
        scanf("%d", &k);
        auto &c = lt[k];
        printf("%d ", (int)c.size());
        for (int i = (int)c.size() - 1; i >= 0; i--) printf("%d ", c[i]);
        puts("");
    }
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:35:15: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |     for (scanf("%d", &t); t--; ) {
      |          ~~~~~^~~~~~~~~~
Main.cpp:36:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |         scanf("%d", &k);
      |         ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 4051 ms 55924 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4051 ms 55924 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4051 ms 55924 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4051 ms 55924 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4051 ms 55924 KB Time limit exceeded
2 Halted 0 ms 0 KB -