Submission #572916

# Submission time Handle Problem Language Result Execution time Memory
572916 2022-06-05T13:32:35 Z moday_morning Permutation (APIO22_perm) C++17
0 / 100
1 ms 340 KB
#include "perm.h"
#include <bits/stdc++.h>
#define ll long long
using namespace std;

vector<int> construct_permutation(ll k)
{
    // 90 balls
    vector <int> ans;
    vector <int> bytes;
    for (int i = 63; i >= 1; i--) {
        if (k & (1ll << i) != 0) {
            bytes.push_back(i);
        }
    }
    int mx = bytes[0];
    for (int i = 0; i < mx; i++) {
        ans.push_back(i);
    }
    for (int i = 1; i < bytes.size(); i++) {
        int cur_bit = bytes[i];
        for (int j = 0; j < ans.size(); j++) {
            if (ans[j] >= cur_bit) {
                ans[j]++;
            }
        }
    }
    if (k % 2) {
        for (int j = 0; j < ans.size(); j++) {
            ans[j]++;
        }
        ans.push_back(0);
    }
    return ans;
}

Compilation message

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:12:28: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   12 |         if (k & (1ll << i) != 0) {
      |                 ~~~~~~~~~~~^~~~
perm.cpp:20:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for (int i = 1; i < bytes.size(); i++) {
      |                     ~~^~~~~~~~~~~~~~
perm.cpp:22:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |         for (int j = 0; j < ans.size(); j++) {
      |                         ~~^~~~~~~~~~~~
perm.cpp:29:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |         for (int j = 0; j < ans.size(); j++) {
      |                         ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -