Submission #536951

#TimeUsernameProblemLanguageResultExecution timeMemory
536951joelauSpeedrun (RMI21_speedrun)C++14
29 / 100
44 ms796 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); } if (subtask == 2) { int deg[N+5]; memset(deg,0,sizeof(deg)); for (int i = 1; i < N; ++i) deg[A[i]]++, deg[B[i]]++; int x = 1; for (int i = 1; i <= N; ++i) if (deg[i] > deg[x]) x = i; setHintLen(20); for (int i = 0; i < 20; ++i) for (int j = 1; j <= N; ++j) if (x & (1<<i)) setHint(j,i+1,1); } } int n; void dfs (int x, int p) { for (int i = 1; i <= n; ++i) if (i != p && getHint(i)) { goTo(i); dfs(i,x); } if (p != -1) goTo(p); } void speedrun(int subtask, int N, int start) { int len = getLength(); if (subtask == 1) { n = N; dfs(start,-1); } if (subtask == 2) { bitset<1005> visited; visited[start] = 1; int x = 0; for (int i = 0; i < 20; ++i) if (getHint(i+1)) x |= (1<<i); if (start != x) goTo(x), visited[x] = 1; for (int i = 1; i <= N; ++i) if (!visited[i]) goTo(i), goTo(x); } }

Compilation message (stderr)

speedrun.cpp: In function 'void speedrun(int, int, int)':
speedrun.cpp:32:9: warning: unused variable 'len' [-Wunused-variable]
   32 |     int len = getLength();
      |         ^~~
#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...