답안 #1036529

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1036529 2024-07-27T13:33:33 Z andrei_c1 Present (RMI21_present) C++17
29 / 100
323 ms 14300 KB
/**
* user:  chertes-cab
* fname: Andrei
* lname: Chertes
* task:  Present
* score: 29.0
* date:  2021-12-16 08:14:57.934784
*/
#include <bits/stdc++.h>

using namespace std;

const int maxlen = 25;

bool vis[maxlen + 1];
int st[maxlen + 1];
int mask;
vector<int> v;

bool valid(int p) {
    if(p == 1) {
        return 1;
    }

    for(int i = 1; i < p; i++) {
        if(!vis[__gcd(st[i], st[p])]) {
            return 0;
        }
    }

    return 1;
}

void bkt(int p) {
    for(int i = st[p - 1] + 1; i <= maxlen; i++) {
        st[p] = i;
        vis[i] = 1;
        mask += (1 << (i - 1));


        if(p <= maxlen && valid(p)) {
            v.push_back(mask);
            bkt(p + 1);
        }

        vis[i] = 0;
        mask -= (1 << (i - 1));
    }
}

int T;

int main() {
    ios_base :: sync_with_stdio(false); cin.tie(0); cout.tie(0);

    bkt(1);

    sort(v.begin(), v.end());

    cin >> T;
    while(T--) {
        int K;
        cin >> K;

        if(K == 0) {
            cout << "0\n";
            continue;
        }

        int cnt = 0;
        for(int i = 0; i < maxlen; i++) {
            if(v[K - 1] & (1 << i)) {
                cnt++;
            }
        }

        cout << cnt << " ";
        for(int i = 0; i < maxlen; i++) {
            if(v[K - 1] & (1 << i)) {
                cout << (i + 1) << " ";
            }
        }
        cout << '\n';
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 297 ms 8896 KB Output is correct
2 Correct 298 ms 8616 KB Output is correct
3 Correct 316 ms 8896 KB Output is correct
4 Correct 294 ms 9664 KB Output is correct
5 Correct 315 ms 9664 KB Output is correct
6 Correct 309 ms 10696 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 297 ms 8896 KB Output is correct
2 Correct 298 ms 8616 KB Output is correct
3 Correct 316 ms 8896 KB Output is correct
4 Correct 294 ms 9664 KB Output is correct
5 Correct 315 ms 9664 KB Output is correct
6 Correct 309 ms 10696 KB Output is correct
7 Correct 320 ms 9920 KB Output is correct
8 Correct 319 ms 9920 KB Output is correct
9 Correct 310 ms 10440 KB Output is correct
10 Correct 312 ms 9920 KB Output is correct
11 Correct 312 ms 9264 KB Output is correct
12 Correct 313 ms 10352 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 297 ms 8896 KB Output is correct
2 Correct 298 ms 8616 KB Output is correct
3 Correct 316 ms 8896 KB Output is correct
4 Correct 294 ms 9664 KB Output is correct
5 Correct 315 ms 9664 KB Output is correct
6 Correct 309 ms 10696 KB Output is correct
7 Correct 320 ms 9920 KB Output is correct
8 Correct 319 ms 9920 KB Output is correct
9 Correct 310 ms 10440 KB Output is correct
10 Correct 312 ms 9920 KB Output is correct
11 Correct 312 ms 9264 KB Output is correct
12 Correct 313 ms 10352 KB Output is correct
13 Runtime error 323 ms 14300 KB Execution killed with signal 11
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 297 ms 8896 KB Output is correct
2 Correct 298 ms 8616 KB Output is correct
3 Correct 316 ms 8896 KB Output is correct
4 Correct 294 ms 9664 KB Output is correct
5 Correct 315 ms 9664 KB Output is correct
6 Correct 309 ms 10696 KB Output is correct
7 Correct 320 ms 9920 KB Output is correct
8 Correct 319 ms 9920 KB Output is correct
9 Correct 310 ms 10440 KB Output is correct
10 Correct 312 ms 9920 KB Output is correct
11 Correct 312 ms 9264 KB Output is correct
12 Correct 313 ms 10352 KB Output is correct
13 Runtime error 323 ms 14300 KB Execution killed with signal 11
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 297 ms 8896 KB Output is correct
2 Correct 298 ms 8616 KB Output is correct
3 Correct 316 ms 8896 KB Output is correct
4 Correct 294 ms 9664 KB Output is correct
5 Correct 315 ms 9664 KB Output is correct
6 Correct 309 ms 10696 KB Output is correct
7 Correct 320 ms 9920 KB Output is correct
8 Correct 319 ms 9920 KB Output is correct
9 Correct 310 ms 10440 KB Output is correct
10 Correct 312 ms 9920 KB Output is correct
11 Correct 312 ms 9264 KB Output is correct
12 Correct 313 ms 10352 KB Output is correct
13 Runtime error 323 ms 14300 KB Execution killed with signal 11
14 Halted 0 ms 0 KB -