Submission #1119351

#TimeUsernameProblemLanguageResultExecution timeMemory
1119351BulaSpeedrun (RMI21_speedrun)C++17
100 / 100
213 ms1388 KiB
#include "speedrun.h" #include<bits/stdc++.h> using namespace std; const int Nx = 1e3 + 5; vector<int> adj[Nx], par(Nx), ord; void dfs(int v, int p){ par[v] = p; ord.push_back(v); for(auto x : adj[v]){ if(x == p) continue; dfs(x, v); } } void assignHints(int subtask, int n, int A[], int B[]){ for(int i = 1; i <= n - 1; i++){ adj[A[i]].push_back(B[i]); adj[B[i]].push_back(A[i]); } setHintLen(20); dfs(1, 0); for(int i = 1; i <= n; i++){ for(int j = 0; j < 10; j++){ if(par[i] & (1 << j)) setHint(i, j + 1, 1); } } for(int i = 1; i < ord.size(); i++){ for(int j = 0; j < 10; j++){ if(ord[i] & (1 << j)) setHint(ord[i - 1], j + 11, 1); } } } void speedrun(int subtask, int n, int start){ while(start != 1){ int p = 0; for(int j = 1; j <= 10; j++){ p += getHint(j) * (1 << (j - 1)); } goTo(p); start = p; } set<int> st; int targ = 0, cur = start; while(st.size() < n){ st.insert(cur); int p = 0, nxt = 0; for(int j = 1; j <= 10; j++){ p += getHint(j) * (1 << (j - 1)); nxt += getHint(j + 10) * (1 << (j - 1)); } if(targ > 0 && goTo(targ)){ cur = targ; targ = 0; }else if(nxt > 0 && st.find(nxt) == st.end() && goTo(nxt)){ cur = nxt; } else{ goTo(p); cur = p; if(targ == 0) targ = nxt; } } }

Compilation message (stderr)

speedrun.cpp: In function 'void assignHints(int, int, int*, int*)':
speedrun.cpp:26:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for(int i = 1; i < ord.size(); i++){
      |                    ~~^~~~~~~~~~~~
speedrun.cpp: In function 'void speedrun(int, int, int)':
speedrun.cpp:44:21: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   44 |     while(st.size() < n){
      |           ~~~~~~~~~~^~~
#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...