Submission #1110843

#TimeUsernameProblemLanguageResultExecution timeMemory
1110843elotelo966Arranging Shoes (IOI19_shoes)C++17
0 / 100
1 ms504 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; //#define int long long #define OYY LLONG_MAX #define mod 1000000007 #define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define FOR for(int i=1;i<=n;i++) #define mid (start+end)/2 #define lim 300005 #define fi first #define se second int n,cev,as_cev=INT_MAX; vector<int> v; int dizi[lim]; inline void brute(int sira,int mask){ //cout<<sira<<" "<<mask<<endl; if(sira>n){ bool stop=1; /*FOR{ cout<<dizi[i]<<" "; } */ FOR{ if(dizi[i]<0 && dizi[i]==-dizi[i+1]){i++;continue;} stop=0; break; } if(stop)as_cev=min(as_cev,cev); return ; } FOR{ if(mask&(1<<i))continue; dizi[sira]=v[i-1]; cev+=abs(sira-i); brute(sira+1,mask|(1<<(i-1))); cev-=abs(sira-i); } } long long count_swaps(std::vector<int> s) { n=s.size(); for(auto x:s){ v.push_back(x); } //cout<<n<<" ppp"<<endl; brute(1,0); return as_cev/2; } /* int main(){ //faster int m;cin>>m; vector<int> vv; for(int i=1;i<=m;i++){ int x;cin>>x; vv.push_back(x); } cout<<count_swaps(vv)<<'\n'; return 0; } */
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...