Submission #982747

# Submission time Handle Problem Language Result Execution time Memory
982747 2024-05-14T17:10:39 Z vjudge1 Permutation (APIO22_perm) C++17
91.3333 / 100
2 ms 348 KB
// hola soy Dember :D
// 31/03/2024

#include <bits/stdc++.h>

#define ll long long
#define pll pair<ll,ll>
#define F first
#define S second 
#define Z size()
#define pb push_back
#define bp pop_back
#define fo(x,y,z) for(ll x=y; x<=z; x++)
#define of(x,y,z) for(ll x=y; x>=z; x--)
#define all(n) n.begin(), n.end()
#define arr(x,y,z) x+y, x+y+z
#define dd double

using namespace std;
 
vector<int> construct_permutation(ll k){
    vector<int> ans, v;
    ll xd, zd;
    fo(i,0,__lg(k))
        if((k>>i)&1)xd=i, v.pb(i);
    
    
    fo(i,0,xd-1)ans.pb(i);
    
    v.bp();
    reverse(all(v));
    
    for(auto u:v){
        fo(i,u,ans.Z-1)ans[i]++;
        ans.pb(u);
    }
    
	return ans;
}

Compilation message

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:13:32: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 | #define fo(x,y,z) for(ll x=y; x<=z; x++)
......
   34 |         fo(i,u,ans.Z-1)ans[i]++;
      |            ~~~~~~~~~~~          
perm.cpp:34:9: note: in expansion of macro 'fo'
   34 |         fo(i,u,ans.Z-1)ans[i]++;
      |         ^~
perm.cpp:23:12: warning: unused variable 'zd' [-Wunused-variable]
   23 |     ll xd, zd;
      |            ^~
perm.cpp:13:32: warning: 'xd' may be used uninitialized in this function [-Wmaybe-uninitialized]
   13 | #define fo(x,y,z) for(ll x=y; x<=z; x++)
      |                                ^~
perm.cpp:23:8: note: 'xd' was declared here
   23 |     ll xd, zd;
      |        ^~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 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 348 KB Output is correct
8 Partially correct 1 ms 348 KB Partially correct
9 Correct 1 ms 348 KB Output is correct
10 Partially correct 2 ms 348 KB Partially correct
11 Partially correct 1 ms 348 KB Partially correct
12 Partially correct 1 ms 348 KB Partially correct
13 Partially correct 1 ms 348 KB Partially correct