Submission #535724

#TimeUsernameProblemLanguageResultExecution timeMemory
535724sam571128Group Photo (JOI21_ho_t3)C++17
12 / 100
1896 ms312 KiB
#include <bits/stdc++.h> #define int long long #define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); using namespace std; signed main(){ fastio int n; cin >> n; int arr[n], tmp[n], idk[n]; for(auto &x : arr) cin >> x; int ans = 1e18; for(int mask = 0; mask < (1<<n); mask++){ vector<int> v; for(int i = 0;i < n;i++){ if(mask&(1<<i)) v.push_back(i); } for(int i = 0;i < n;i++){ tmp[i] = i+1; } for(int i = 1;i < v.size();i += 2){ reverse(tmp+v[i-1],tmp+v[i]+1); } for(int i = 0;i < n;i++){ for(int j = 0;j < n;j++){ if(tmp[i]==arr[j]) idk[i] = j; } } int cnt = 0; for(int i = 0;i < n;i++){ for(int j = 0;j < i;j++){ if(idk[j] > idk[i]){ cnt++; } } } ans = min(ans,cnt); } cout << ans << "\n"; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:28:25: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |         for(int i = 1;i < v.size();i += 2){
      |                       ~~^~~~~~~~~~
#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...