Submission #647008

#TimeUsernameProblemLanguageResultExecution timeMemory
647008ksu2009enSpeedrun (RMI21_speedrun)C++17
33 / 100
255 ms844 KiB
#include "speedrun.h" #include <iostream> #include <vector> #include <string> #include <math.h> #include <cmath> #include <iomanip> #include <cstdio> #include <algorithm> #include <map> #include <set> #include <queue> #include <stack> #include <deque> #include <bitset> #include <cstring> #include <unordered_map> using namespace std; typedef long long ll; vector<ll>d[1007]; void assignHints(int subtask, int n, int a[], int b[]) { /* your solution here */ for(int i = 1; i < n; i++){ d[a[i]].push_back(b[i]); d[b[i]].push_back(a[i]); } setHintLen(316); int sz = sqrt(n); for(int i = 1; i <= n; i++){ if(d[i].size() <= sz){ // the degree is less/equal than sqrt(n) => we can build an adjestancy list (10 bits per vertex) int pos = 1; for(auto x: d[i]){ for(int j = pos; j <= pos + 9; j++){ if((x >> (j - pos)) % 2 != 0) setHint(i, j, 1); } pos += 10; } } // else: leave it as it is, we're gonna check all N nodes using goTo later in speedrun } } bool used[1007]; void dfs(ll v, ll par, int &n){ used[v] = true; bool ok = false; for(int i = 1; i <= 316; i++){ if(getHint(i)) ok = true; } if(!ok){ // there are no set bits, thus this node has degree > sqrt(n) and we can traverse over all N nodes using goTo (the amount of such nodes will not exceed sqrt(N) - why? idk, just seems logical, search for proof) for(int i = 1; i <= n; i++){ if(goTo(i)) dfs(i, v, n); } } else{ // this node has its adjactency list for(int i = 1; i + 9 <= 316; i += 10){ // the start of new code ll v2 = 0; for(int j = 9; j >= 0; j--){ v2 *= 2; if(getHint(i + j)) v2++; } if(v2 == 0) // there is an end in the list! break; if(!used[v2]){ goTo(v2); dfs(v2, v, n); } } } if(par != -1) // go back, from where we've come goTo(par); } void speedrun(int subtask, int n, int start) { /* your solution here */ dfs(start, -1, n); }

Compilation message (stderr)

speedrun.cpp: In function 'void assignHints(int, int, int*, int*)':
speedrun.cpp:37:24: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   37 |         if(d[i].size() <= sz){ // the degree is less/equal than sqrt(n) => we can build an adjestancy list (10 bits per vertex)
      |            ~~~~~~~~~~~~^~~~~
#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...