Submission #536969

#TimeUsernameProblemLanguageResultExecution timeMemory
536969joelauSpeedrun (RMI21_speedrun)C++14
48 / 100
120 ms836 KiB
#include "speedrun.h" #include <bits/stdc++.h> using namespace std; vector<int> lst[1005]; 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); } if (subtask == 3) { setHintLen(20); for (int i = 1; i < N; ++i) lst[A[i]].push_back(B[i]), lst[B[i]].push_back(A[i]); for (int i = 1; i <= N; ++i) { for (int j = 0; j < 10; ++j) if (lst[i][0] & (1<<j)) setHint(i,j+1,1); if (lst[i].size() > 1) { for (int j = 0; j < 10; ++j) if (lst[i][1] & (1<<j)) setHint(i,j+11,1); } else { for (int j = 0; j < 10; ++j) if (i & (1<<j)) setHint(i,j+11,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 dfs2 (int x, int p) { int a = 0, b = 0; for (int i = 0; i < 10; ++i) if (getHint(i+1)) a |= (1<<i); for (int i = 0; i < 10; ++i) if (getHint(i+11)) b |= (1<<i); if (a != p) goTo(a), dfs2(a,x); if (b != x && b != p) goTo(b), dfs2(b,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); } if (subtask == 3) { n = N; dfs2(start,-1); } }

Compilation message (stderr)

speedrun.cpp: In function 'void speedrun(int, int, int)':
speedrun.cpp:56:9: warning: unused variable 'len' [-Wunused-variable]
   56 |     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...