Submission #1110850

#TimeUsernameProblemLanguageResultExecution timeMemory
1110850elotelo966Arranging Shoes (IOI19_shoes)C++17
10 / 100
1100 ms3656 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]<<" "; } cout<<endl<<endl;*/ 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-1)))continue; int eski=dizi[sira]; dizi[sira]=v[i-1]; cev+=abs(sira-i); brute(sira+1,mask|(1<<(i-1))); cev-=abs(sira-i); dizi[sira]=eski; } } long long count_swaps(std::vector<int> s) { n=s.size(); int tut=1; for(auto x:s){ v.push_back(x); dizi[tut++]=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...