Submission #959329

# Submission time Handle Problem Language Result Execution time Memory
959329 2024-04-08T01:57:06 Z zeta7532 Permutation (APIO22_perm) C++17
100 / 100
1 ms 384 KB
#include "perm.h"
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
const ll mod = 998244353;
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define faster ios::sync_with_stdio(false);cin.tie(nullptr)

std::vector<int> construct_permutation(long long k)
{
    if(k==1) return {};
    if(k==2) return {0};
    if(k==3) return {1,0};
    if(k%4==0){
        vector<int> A=construct_permutation(k/4);
	    A.push_back(A.size());
	    A.push_back(A.size());
	    return A;
    }
    if(k%4==1){
        vector<int> A=construct_permutation(k/4);
	    A.push_back(A.size());
	    A.push_back(A.size());
	    rep(i,A.size()) A[i]++;
	    A.push_back(0);
	    return A;
    }
    if(k%4==2){
        vector<int> A=construct_permutation(k/4);
	    A.push_back(A.size());
	    rep(i,A.size()) A[i]++;
	    A.push_back(0);
	    A.push_back(A.size());
	    return A;
    }
    if(k%4==3){
        vector<int> A=construct_permutation(k/4);
        if(A.size()>=2){
            ll id0=-1,id1=-1;
            rep(i,A.size()){
                if(A[i]==0) id0=i;
                if(A[i]==1) id1=i;
            }
            if(id0>id1){
                A.push_back(A.size());
	            A.push_back(A.size());
	            rep(i,A.size()) if(A[i]>=2) A[i]++;
	            A.push_back(2);
	            return A;
            }
        }
	    A.push_back(A.size());
	    rep(i,A.size()) A[i]++;
	    A.push_back(0);
	    A.push_back(A.size());
	    rep(i,A.size()) A[i]++;
	    A.push_back(0);
	    return A;
    }
}

Compilation message

perm.cpp: In function 'std::vector<int> construct_permutation(long long int)':
perm.cpp:11:30: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 | #define rep(i,n) for(ll i=0;i<n;i++)
......
   30 |      rep(i,A.size()) A[i]++;
      |          ~~~~~~~~~~           
perm.cpp:30:6: note: in expansion of macro 'rep'
   30 |      rep(i,A.size()) A[i]++;
      |      ^~~
perm.cpp:11:30: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 | #define rep(i,n) for(ll i=0;i<n;i++)
......
   37 |      rep(i,A.size()) A[i]++;
      |          ~~~~~~~~~~           
perm.cpp:37:6: note: in expansion of macro 'rep'
   37 |      rep(i,A.size()) A[i]++;
      |      ^~~
perm.cpp:11:30: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 | #define rep(i,n) for(ll i=0;i<n;i++)
......
   46 |             rep(i,A.size()){
      |                 ~~~~~~~~~~    
perm.cpp:46:13: note: in expansion of macro 'rep'
   46 |             rep(i,A.size()){
      |             ^~~
perm.cpp:11:30: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 | #define rep(i,n) for(ll i=0;i<n;i++)
......
   53 |              rep(i,A.size()) if(A[i]>=2) A[i]++;
      |                  ~~~~~~~~~~   
perm.cpp:53:14: note: in expansion of macro 'rep'
   53 |              rep(i,A.size()) if(A[i]>=2) A[i]++;
      |              ^~~
perm.cpp:11:30: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 | #define rep(i,n) for(ll i=0;i<n;i++)
......
   59 |      rep(i,A.size()) A[i]++;
      |          ~~~~~~~~~~           
perm.cpp:59:6: note: in expansion of macro 'rep'
   59 |      rep(i,A.size()) A[i]++;
      |      ^~~
perm.cpp:11:30: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 | #define rep(i,n) for(ll i=0;i<n;i++)
......
   62 |      rep(i,A.size()) A[i]++;
      |          ~~~~~~~~~~           
perm.cpp:62:6: note: in expansion of macro 'rep'
   62 |      rep(i,A.size()) A[i]++;
      |      ^~~
perm.cpp:66:1: warning: control reaches end of non-void function [-Wreturn-type]
   66 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct