Submission #524432

#TimeUsernameProblemLanguageResultExecution timeMemory
524432EliteCallsYouBeautiful row (IZhO12_beauty)C++17
0 / 100
3067 ms296 KiB
# include <bits/stdc++.h> using namespace std ; //############################################################################ # define read(a)/**/for(int i=0;i<int(sizeof(a)/sizeof(a[0]));i++){cin>>a[i];} # define print(x)/**/for(auto zx:x){cout<<zx<<' ';} const char* tochar(string a){return a.c_str();} void files(){freopen("mootube.in","r",stdin);freopen("mootube.out","w",stdout);} void speed(){ios_base::sync_with_stdio(false);cin.tie(0);} int gcd(int a,int b){if(!b){return a;}a%=b;return gcd(b,a);} int lcm(int a,int b){return a /gcd(a,b) * b;} //########################################################################### const int N = 2501 ; const int MOD = 1e9+7 ; //########################################################################### void hack(){} //########################################################################### int ans, n, ar[21] ; bool used[21] ; void rec ( int pos, int last ){ if ( pos == n ){ ans ++ ; return ; } for ( int i = 0 ; i < n ; i ++ ){ if ( used[i] ){continue;} if ( last == -1 ){ used[i] = true ; rec(pos+1,ar[i]) ; used[i] = false ; } else{ int a = 0, b = 0 ; int cur_a = ar[i], cur_b = last ; while ( true ){ if ( !cur_a && !cur_b ){ break ; } if ( cur_a ){ if ( cur_a % 2 == 1 ){ a ++ ; } cur_a /= 2 ; } if ( cur_b ){ if ( cur_b % 2 == 1 ){ b ++ ; } cur_b /= 2 ; } } if ( a == b ){ used[i] = true ; rec(pos+1,ar[i]) ; used[i] = false ; continue ; } /////////////////////// a = b = 0 ; cur_a = ar[i], cur_b = last ; while ( true ){ if ( !cur_a && !cur_b ){ break ; } if ( cur_a ){ if ( cur_a % 3 == 1 ){ a ++ ; } cur_a /= 3 ; } if ( cur_b ){ if ( cur_b % 3 == 1 ){ b ++ ; } cur_b /= 3 ; } } if ( a == b ){ used[i] = true ; rec(pos+1,ar[i]) ; used[i] = false ; } /////////////////////// } } } int main(){ cin >> n ; for ( int i = 0 ; i < n ; i ++ ){ cin >> ar[i] ; } rec(0,-1) ; cout << ans << '\n' ; }

Compilation message (stderr)

beauty.cpp: In function 'void files()':
beauty.cpp:7:21: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 | void files(){freopen("mootube.in","r",stdin);freopen("mootube.out","w",stdout);}
      |              ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
beauty.cpp:7:53: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 | void files(){freopen("mootube.in","r",stdin);freopen("mootube.out","w",stdout);}
      |                                              ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...