Submission #725861

#TimeUsernameProblemLanguageResultExecution timeMemory
725861Vu_CG_CoderPermutation (APIO22_perm)C++17
91.33 / 100
2 ms340 KiB
/* [Author : Hoang Duy Vu] - THPT Chuyen Nguyen Du    */
//#pragma GCC optimize(" unroll-loops")
//#pragma gcc optimize("Ofast")
//#pragma GCC optimization("Ofast")
//#pragma optimize(Ofast)
#include "perm.h"
#include <bits/stdc++.h>
#define All(x) (x).begin(),(x).end()
#define ll long long
#define C make_pair
#define fi first
#define se second
#define two second.first
#define thr second.second
#define TASK "txt"
using namespace std;
template<typename T> bool maximize(T &res, const T &val) {
	if (res < val) { res = val; return true; } return false; }
template<typename T> bool minimize(T &res, const T &val) {
	if (res > val) { res = val; return true; } return false; }

typedef pair<int,int> ii;
typedef pair<int,ii> iii;
const int LOG = 20;
const int INF = 1e9 + 7;
const ll LNF = 1e18 + 7;
const int mod = 1e9 + 7;
const int N = 61;

vector<int> construct_permutation(long long k)
{
	int ok =  0;
	vector <int> t;
	t.assign(120,-1);
	int l = 0;

	for (ll i = 59 ; i >= 0 ; i--)
	if (k&(1ll<<i))
	{
		if (!ok)
		{
			ok = 1;
			for (int j = 1; l < i ; j += 2,l++) t[j] = l;
		}
		else 
		{
			t[i*2] = l++;
		}
	}

	vector <int> res;

	for (int i = 0 ; i < t.size() ; i++) if (t[i] != -1) res.push_back(t[i]);

	return res;
}



Compilation message (stderr)

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:53:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |  for (int i = 0 ; i < t.size() ; i++) if (t[i] != -1) res.push_back(t[i]);
      |                   ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...