Submission #394786

#TimeUsernameProblemLanguageResultExecution timeMemory
394786Nima_NaderiSwap (BOI16_swap)C++14
10 / 100
41 ms332 KiB
//In the name of God #pragma GCC optimize("Ofast") #include<bits/stdc++.h> using namespace std; //typedef long long ll; typedef int ll; const ll MXN = 20 + 10; ll n; ll A[MXN], B[MXN], C[MXN], ANS[MXN]; bool check(){ for(int i = 1; i <= n; i ++){ if(ANS[i] == B[i]) continue; return (B[i] < ANS[i]); } return 0; } int main(){ ios::sync_with_stdio(0);cin.tie(0); cout.tie(0); cin >> n; for(int i = 1; i <= n; i ++) cin >> A[i]; memcpy(ANS, A, sizeof A); if(n > 20) return 0; for(int mask = 0; mask < (1LL << (n - 1)); mask ++){ memcpy(B, A, sizeof A); for(int i = 2; i <= n; i ++){ if((mask >> (i - 2)) & 1LL){ swap(B[i], B[i / 2]); } } if(check()){ memcpy(ANS, B, sizeof B); } } for(int i = 1; i <= n; i ++) cout << ANS[i] << ' '; cout <<'\n'; return 0; } //! N.N

Compilation message (stderr)

swap.cpp: In function 'int main()':
swap.cpp:35:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   35 |  for(int i = 1; i <= n; i ++) cout << ANS[i] << ' '; cout <<'\n';
      |  ^~~
swap.cpp:35:54: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   35 |  for(int i = 1; i <= n; i ++) cout << ANS[i] << ' '; cout <<'\n';
      |                                                      ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...