Submission #383124

#TimeUsernameProblemLanguageResultExecution timeMemory
383124Pichon5Mechanical Doll (IOI18_doll)C++17
6 / 100
107 ms8132 KiB
#include "doll.h" #include<bits/stdc++.h> #define lcm(a,b) (a/__gcd(a,b))*b #define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define ll long long int #define vi vector<int> #define vll vector<ll> #define pb push_back #define F first #define S second #define mp make_pair //salida rapida "\n" //DECIMALES fixed<<sp(n)<<x<<endl; //gcd(a,b)= ax + by //lCB x&-x //set.erase(it) - ersases the element present at the required index//auto it = s.find(element) //set.find(element) - iterator pointing to the given element if it is present else return pointer pointing to set.end() //set.lower_bound(element) - iterator pointing to element greater than or equal to the given element //set.upper_bound(element) - iterator pointing to element greater than the given element // | ^ //__builtin_popcount(x) using namespace std; void create_circuit(int m,vi A) { int n = A.size(); vi C(m + 1,-1); vi vis(m+1,0); C[0]=A[0]; int num=0; for(int i=0;i<n;i++)vis[A[i]]++; for(int i=1;i<=m;i++){ if(vis[i]==0)C[i]=0; if(vis[i]==2)num++; if(vis[i]>=3)num+=3; } vi X(num),Y(num); vi S(m+1,-1); vi curr(m+1,1); int cnt=1; for(int i=0;i<n;i++){ if(vis[A[i]]==1){ if(i==n-1){ C[A[i]]=0; }else{ C[A[i]]=A[i+1]; } } if(vis[A[i]]==2){ if(S[A[i]]==-1){ C[A[i]]=-cnt; S[A[i]]=cnt; X[cnt-1]=A[i+1]; cnt++; }else{ int aux=S[A[i]]; if(i==n-1){ Y[aux-1]=0; }else{ Y[aux-1]=A[i+1]; } } } if(vis[A[i]]==3){ if(S[A[i]]==-1){ C[A[i]]=-cnt; X[cnt-1]=-(cnt+1); X[cnt]=-cnt; Y[cnt-1]=-(cnt+2); X[cnt+1]=A[i+1]; S[A[i]]=cnt; cnt++;cnt++;cnt++; curr[A[i]]=3; }else{ if(curr[A[i]]==3){ int aux=S[A[i]]; Y[aux]=A[i+1]; curr[A[i]]=3; }else{ int aux=S[A[i]]; if(i==n-1){ Y[aux+1]=0; }else{ Y[aux+1]=A[i+1]; } } } } if(vis[A[i]]==4){ if(S[A[i]]==-1){ S[A[i]]=cnt; C[A[i]]=-cnt; X[cnt-1]=-(cnt+1); Y[cnt-1]=-(cnt+2); X[cnt]=A[i+1]; cnt+=3; curr[A[i]]=2; }else{ int aux=S[A[i]]; if(curr[A[i]]==2){ X[aux]=A[i+1]; } if(curr[A[i]]==3){ Y[aux]=A[i+1]; } if(curr[A[i]]==4){ if(i==n-1){ Y[aux+1]=0; }else{ Y[aux+1]=A[i+1]; } } } } } answer(C, X, Y); } //3 4 1 2 1 3 //4 4 1 2 1 3
#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...