# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
857716 | 2023-10-06T16:21:19 Z | Vanio | Speedrun (RMI21_speedrun) | C++17 | 0 ms | 0 KB |
#include<bits/stdc++.h> #include "speedrun.h" using namespace std; void assignHints(int subtask, int n, int a[], int b[]){ if(subtask==1){ int i; setHintLen(n); for(i=1;i<n;i++){ setHint(a[i],b[i],1); setHint(b[i],a[i],1); } } if(subtask==2){ int c; if(a[2]==a[1] || a[2]==b[1]) c=a[2]; else c=b[2]; int l=1,h[20]; while(c>0){ h[l]=c%2; c/=2; l++; } setHintLen(l-1); int j; for(i=1;i<=n;i++){ if(i==c) continue; for(j=1;j<l;j++) setHint(i,j,h[j]); } } } int n; bool f[1001]; void rec(int k, int p){ int i; f[k]=1; for(i=1;i<=n;i++){ if(getHint(i) && !f[i]){ goTo(i); rec(i,k); } } if(p==0) return; goTo(p); } void speedrun(int st, int N, int start){ n=N; if(subtask==1) rec(start,0); if(subtask==2){ int i,F=0,c=0,t=1; int l = getLength(); for(i=1;i<=l;i++) if(getHint(i)==1){F=1; break;} if(F){ for(i=1;i<l;i++) t*=2; for(i=l-1;i>=1;i--){ c+=getHint(i)*t; t/=2; } goTo(c); } else c=start; for(i=1;i<=n;i++){ if(i==c) continue; goTo(i); goTo(c); } } }