Submission #1080443

#TimeUsernameProblemLanguageResultExecution timeMemory
1080443modwwePermutation (APIO22_perm)C++17
91.33 / 100
2 ms600 KiB
#pragma GCC optimize("Ofast,unroll-loops")
#include<bits/stdc++.h>
//#define int long long
#define ll long long
#define down cout<<'\n';
#define debug cout<<" cucuucucuuu",down
#define NHP     ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
#define modwwe  int t;cin>>t; while(t--)
#define bit(i,j) (i>>j&1)
#define sobit(a) __builtin_popcountll(a)
#define task "test"
#define fin(x) freopen(x".inp","r",stdin)
#define fou(x) freopen(x".ans","w",stdout)
#define pb push_back
#define checktime   cerr << (double)clock() / CLOCKS_PER_SEC * 1000  << " ms";
using namespace std;
#define getchar_unlocked getchar

inline int scan()
{
    char c = getchar_unlocked();
    int x = 0;
    while(c<'0'||c>'9')
    {
        c=getchar_unlocked();
    }
    while(c>='0'&&c<='9')
    {
        x=(x<<1)+(x<<3)+c-'0';
        c=getchar_unlocked();
    }
    return x;
}

void phongbeo();
const int inf=1e9;
const int mod2=1e9+9;
const int  mod1=998244353;
struct icd
{
    long double a;
    int b;
};
struct ib
{
    int a;
    int b;
};
struct ic
{
    int a,b,c;
};
struct id
{
    int a,b,c,d;
};
struct ie
{
    int a,b,c,d,e;

};

int n,m,s1,s2,s3,s4,sf,k,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,dem=0,s33,dem3,dem4,l,r,mid;
int  i,s10,s12;
int kk;
int el=29;
vector<int> construct_permutation(long long k)
{
  set<int> s;
vector<int> v;
vector<int> v2;
vector<int> v3;
 dem=0;
        for(int i=59; i>=0; --i)
    {
        if(bit(k,i))
        {
            v.pb(i);
            if(dem==0) dem=i;
            else dem++;
        }
    }
    dem--;
    for(int i=0; i<=dem; i++)
        s.insert(i);
    reverse(v.begin(),v.end());
    for(int i=0; i<v.size(); i++)
    {
        if(i+1==v.size())
        {

            for (auto it = s.begin(); it != s.end(); ++it)
                v3.pb(*it);
            reverse(v3.begin(),v3.end());
            for(auto x:v3)
                v2.pb(x);
        }
        else
        {
            auto x=s.begin();
            for(int j=1; j<=v[i]; j++)
                x++;
            v2.pb(*x);
            s.erase(x);
        }

    }
    reverse(v2.begin(),v2.end());
    return v2;
}
/*main()
 {
   freopen ("test.inp", "r", stdin);
				freopen ("test.ans", "w", stdout);

	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int q;
	cin >> q;
	while ( q-- ) {
		ll k;
	cin >> k;
		vector <int> kk = construct_permutation(k);
		for (int i : kk) {
			cout << i << " ";
		}
		cout << "\n";
 }
 }
*/

Compilation message (stderr)

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