Submission #1139626

#TimeUsernameProblemLanguageResultExecution timeMemory
1139626KasymKPermutation Recovery (info1cup17_permutation)C++20
0 / 100
1093 ms324 KiB
#include "bits/stdc++.h" using namespace std; #define ff first #define ss second #define all(v) v.begin(), v.end() #define ll long long #define pb push_back #define pii pair<int, int> #define pli pair<ll, int> #define pll pair<ll, ll> #define tr(i, c) for(auto i = c.begin(); i != c.end(); ++i) #define wr puts("----------------") template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;} template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;} const int N = 15; ll dp[N], q[N]; int main(){ int n; scanf("%d", &n); for(int i = 1; i <= n; ++i) scanf("%d", q+i); vector<int> p; p.pb(0); for(int i = 1; i <= n; ++i) p.pb(i); do{ memset(dp, 0, sizeof dp); dp[0]=1; for(int i = 1; i <= n; ++i) for(int j = 0; j < i; ++j) if(p[j]<p[i]) dp[i]+=dp[j]; dp[0]=0; for(int i = 1; i <= n; ++i) dp[i]+=dp[i-1]; bool ok=1; for(int i = 1; i <= n and ok; ++i) ok&=(dp[i]==q[i]); if(ok){ for(int i = 1; i <= n; ++i) printf("%d ", p[i]); puts(""); exit(0); } }while(next_permutation(p.begin()+1, p.end())); return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:22:25: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   22 |                 scanf("%d", q+i);
      |                        ~^   ~~~
      |                         |    |
      |                         int* long long int*
      |                        %lld
Main.cpp:20:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |         scanf("%d", &n);
      |         ~~~~~^~~~~~~~~~
Main.cpp:22:22: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |                 scanf("%d", q+i);
      |                 ~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...