Submission #383068

#TimeUsernameProblemLanguageResultExecution timeMemory
383068Pichon5Mechanical Doll (IOI18_doll)C++17
0 / 100
1 ms332 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]==2)num++; if(vis[i]==0)C[i]=i; } vi S(m+1,-1); int cnt=0; vi X(num),Y(num); for(int i=0;i<n;i++){ if(vis[i]==1){ if(i==n-1){ C[A[i]]=0;continue; } C[A[i]]=A[i+1]; }else{ if(S[A[i]]==-1){ S[A[i]]=cnt; X.pb(A[i+1]); cnt++; }else{ int aux=S[A[i]]; if(i==n-1){ Y[aux]=0; }else{ Y[aux]=A[i+1]; } } } } answer(C, X, Y); }
#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...