Submission #919107

# Submission time Handle Problem Language Result Execution time Memory
919107 2024-01-31T09:47:56 Z Mher777 Permutation (APIO22_perm) C++17
91.3333 / 100
2 ms 348 KB
#include "perm.h"
#include <iostream>
#include <iomanip>
#include <array>
#include <string>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <list>
#include <iterator>
#include <numeric>
#include <complex>
#include <utility>
#include <random>
#include <fstream>
using namespace std;

/* -------------------- Typedefs -------------------- */

typedef int itn;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef float fl;
typedef long double ld;

/* -------------------- Usings -------------------- */

using vi = vector<int>;
using vll = vector<ll>;
using mii = map<int, int>;
using mll = map<ll, ll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

/* -------------------- Defines -------------------- */

#define ff first
#define ss second
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mpr make_pair
#define yes cout<<"Yes\n"
#define no cout<<"No\n"
#define all(x) (x).begin(), (x).end()

/* -------------------- Constants -------------------- */

const int MAX = int(2e9 + 5);
const ll MAXL = ll(1e18) + 5ll;
const ll MOD = ll(1e9 + 7);
const ll MOD2 = ll(998244353);

std::vector<int> construct_permutation(long long k) {
	vi answ = { 0,1,2,3,4,5,6,7,8,9, };
	vi ans;
	bitset<66> bit = k;
	int beg = 0;
	for (int i = 64; i >= 0; --i) {
		if (!bit[i]) continue;
		if (ans.empty()) {
			for (int j = 0; j < i; ++j) ans.pub(j);
			continue;
		}
		for (int j = i; j < ans.size(); ++j) ++ans[j];
		ans.pub(i);
	}
	return ans;
}

Compilation message

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:75:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   75 |   for (int j = i; j < ans.size(); ++j) ++ans[j];
      |                   ~~^~~~~~~~~~~~
perm.cpp:68:6: warning: unused variable 'beg' [-Wunused-variable]
   68 |  int beg = 0;
      |      ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Partially correct 1 ms 348 KB Partially correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Partially correct 1 ms 344 KB Partially correct
9 Correct 1 ms 348 KB Output is correct
10 Partially correct 2 ms 344 KB Partially correct
11 Partially correct 1 ms 344 KB Partially correct
12 Partially correct 1 ms 344 KB Partially correct
13 Partially correct 1 ms 344 KB Partially correct