Submission #686608

# Submission time Handle Problem Language Result Execution time Memory
686608 2023-01-25T14:53:07 Z QwertyPi Present (RMI21_present) C++14
8 / 100
149 ms 33612 KB
#include <bits/stdc++.h>
 
using namespace std;
 
const int all = 32, half = 16;
uint64_t allow[all][1 << half];
uint64_t p2m1[all];

int g[65][65];
int B = 1;
bool ok(uint64_t b){
    for(int i = 0; i < B; i++){
        if((b & (1ULL << i)) && (b & allow[i][b & ((1ULL << i + 1) - 1)]) != b) return false;
    }
    return true;
}


void out(uint64_t b){
    vector<int> v;
    for(int i = 0; i < 64; i++){
        if(b & (1ULL << i)) v.push_back(i + 1);
    }
    cout << v.size() << ' ';
    for(auto i : v) cout << i << ' ';
    cout << endl;
}
 
int main(){
    for(int i = 1; i <= 64; i++) for(int j = 1; j <= 64; j++) g[i - 1][j - 1] = __gcd(i, j) - 1;
    for(int i = 1; i <= all; i++){
        for(int j = 0; j < half; j++){
            uint64_t u = 0;
            for(int k1 = 0; k1 < half; k1++){
                for(int k2 = 0; k2 < all; k2++){
                    if(((1ULL << j) & (1ULL << k1)) && __gcd(i, k2 + 1) == k1 + 1) u |= 1ULL << k2;
                }
            }
            allow[i - 1][1ULL << j] = u;
        }
        for(int j = 0; j < (1ULL << half); j++){
            for(int k1 = 0; k1 < half; k1++){
                if(j & (1ULL << k1)) allow[i - 1][j] |= allow[i - 1][j - (1ULL << k1)];
            }
        }
    }
    int cnt = 0;
 
    int L; cin >> L;
    for(int i = 0; i < L; i++){
        int x; cin >> x;
        B = 0;
        for(int i = 0; ; i++){
            while(i >= (1ULL << B)) B++;
            if(ok(i)) { if(x == 0) { out(i); break; } x--; }
        }
    }
}

Compilation message

Main.cpp: In function 'bool ok(uint64_t)':
Main.cpp:13:63: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   13 |         if((b & (1ULL << i)) && (b & allow[i][b & ((1ULL << i + 1) - 1)]) != b) return false;
      |                                                             ~~^~~
Main.cpp: In function 'int main()':
Main.cpp:41:26: warning: comparison of integer expressions of different signedness: 'int' and 'long long unsigned int' [-Wsign-compare]
   41 |         for(int j = 0; j < (1ULL << half); j++){
      |                        ~~^~~~~~~~~~~~~~~~
Main.cpp:54:21: warning: comparison of integer expressions of different signedness: 'int' and 'long long unsigned int' [-Wsign-compare]
   54 |             while(i >= (1ULL << B)) B++;
      |                   ~~^~~~~~~~~~~~~~
Main.cpp:47:9: warning: unused variable 'cnt' [-Wunused-variable]
   47 |     int cnt = 0;
      |         ^~~
# Verdict Execution time Memory Grader output
1 Correct 117 ms 16660 KB Output is correct
2 Correct 119 ms 16708 KB Output is correct
3 Correct 134 ms 16612 KB Output is correct
4 Correct 123 ms 16608 KB Output is correct
5 Correct 119 ms 16632 KB Output is correct
6 Correct 134 ms 16644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 117 ms 16660 KB Output is correct
2 Correct 119 ms 16708 KB Output is correct
3 Correct 134 ms 16612 KB Output is correct
4 Correct 123 ms 16608 KB Output is correct
5 Correct 119 ms 16632 KB Output is correct
6 Correct 134 ms 16644 KB Output is correct
7 Runtime error 149 ms 33612 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 117 ms 16660 KB Output is correct
2 Correct 119 ms 16708 KB Output is correct
3 Correct 134 ms 16612 KB Output is correct
4 Correct 123 ms 16608 KB Output is correct
5 Correct 119 ms 16632 KB Output is correct
6 Correct 134 ms 16644 KB Output is correct
7 Runtime error 149 ms 33612 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 117 ms 16660 KB Output is correct
2 Correct 119 ms 16708 KB Output is correct
3 Correct 134 ms 16612 KB Output is correct
4 Correct 123 ms 16608 KB Output is correct
5 Correct 119 ms 16632 KB Output is correct
6 Correct 134 ms 16644 KB Output is correct
7 Runtime error 149 ms 33612 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 117 ms 16660 KB Output is correct
2 Correct 119 ms 16708 KB Output is correct
3 Correct 134 ms 16612 KB Output is correct
4 Correct 123 ms 16608 KB Output is correct
5 Correct 119 ms 16632 KB Output is correct
6 Correct 134 ms 16644 KB Output is correct
7 Runtime error 149 ms 33612 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -