Submission #856779

#TimeUsernameProblemLanguageResultExecution timeMemory
856779iulia_morariuSpeedrun (RMI21_speedrun)C++17
21 / 100
27 ms1932 KiB
#include <speedrun.h> #include <bits/stdc++.h> using namespace std; void assignHints (int subtask , int N, int A[], int B[]){ if(subtask == 1){ setHintLen( N ); for(int i = 1; i < N; i++){ setHint( A[i], B[i], 1); setHint( B[i], A[i], 1); } }else{ setHintLen(20); int vf[N + 1]; for(int i = 1; i <= N; i++) vf[i] = 0; for(int i = 1; i < N; i++){ vf[ A[i] ]++; vf[ B[i] ]++; } int nod = 0; for(int i = 1; i <= N; i++){ if(vf[i] == N - 1) nod = i; } for(int i = 1; i < N; i++){ for(int j = 0; j < 20; j++){ bool set = 0; if( (nod & (1 << j)) ) set = 1; setHint(i, j, set ); } } } } int vis[1001]; void dfs(int nd, int n){ vis[nd] = 1; //cout << "Suntem la " << nd << endl; for(int i = 1; i <= n; i++){ if( vis[i] || getHint(i) == 0 ) continue; //cout << " -- > i = " << i << " getHint = " << getHint(i) << endl; goTo(i); vis[i] = 1; dfs(i, n); goTo(nd); } } void speedrun(int subtask , int N, int start ){ if(subtask == 1){ for(int i = 0; i <= N; i++) vis[i] = 0; vis[start] = 1; stack<int> s; s.push(start); dfs(start, N); }else{ int nd = 0; for(int j = 0; j <= 20; j++){ nd += getHint(j) * (1 << j); } if(nd != start){ goTo( nd ); } for(int i = 1; i <= N; i++){ if(i == nd || i == start) continue; goTo(i); goTo(nd); } } }
#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...