Submission #911276

#TimeUsernameProblemLanguageResultExecution timeMemory
911276tosivanmakPermutation (APIO22_perm)C++17
91.33 / 100
2 ms504 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long const ll Log=15; #define MAX 1e18 #define MOD 1000000007 typedef pair<ll,ll> LP; #define ld long double static long long MX=1e18; static bool check_permutation(vector<int> v) { sort(v.begin(),v.end()); for(int i=0;i<v.size();i++) if(v[i]!=i) return 0; return 1; } long long count_increasing(const vector<int>& v) { vector<long long> dp(v.size() + 1, 0); dp[0] = 1; for (int x : v) { for (int i = 0; i <= x; i++) { dp[x+1] += dp[i]; dp[x+1] = min(dp[x+1],MX+1); } } long long result = 0; for (int i = 0; i <= (int)v.size(); i++){ result += dp[i]; result = min(result,MX+1); } return result; } vector<ll>seq; ll cur=1; void bm(ll num){ if(num==0){ return; } if(num&1){ bm(num/2); seq.push_back(cur); cur++; } else{ bm((num-1)/2); seq.push_back(cur); seq.push_back(-cur); cur++; } } vector<int> construct_permutation(ll n){ bm(n-1); // cout<<seq.size()<<'\n'; vector<ll>seq2; for(auto& u: seq){ seq2.push_back(u); } sort(seq2.begin(),seq2.end()); vector<int>ans; for(auto& u: seq){ ans.push_back(lower_bound(seq2.begin(),seq2.end(),u)-seq2.begin()); } cur=1; seq.clear(); return ans; } // int main(){ // ios_base::sync_with_stdio(false); // cin.tie(NULL); cout.tie(NULL); // ll t=1; // // cin>>t; //Remove if 1 testcase // for(int n=1;n<=90;n++){ // vector<int>lol=construct_permutation(n); // for(auto& u: lol){ // cout<<u<<" "; // } // cout<<count_increasing(lol)<<'\n'; // } // }

Compilation message (stderr)

perm.cpp: In function 'bool check_permutation(std::vector<int>)':
perm.cpp:14:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |  for(int i=0;i<v.size();i++)
      |              ~^~~~~~~~~
perm.cpp: At global scope:
perm.cpp:11:13: warning: 'bool check_permutation(std::vector<int>)' defined but not used [-Wunused-function]
   11 | static bool check_permutation(vector<int> v)
      |             ^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...