Submission #847400

#TimeUsernameProblemLanguageResultExecution timeMemory
847400TahirAliyevSpeedrun (RMI21_speedrun)C++17
100 / 100
139 ms2184 KiB
#include "speedrun.h" #include <bits/stdc++.h> using namespace std; const int MAX = 2002; int par[MAX]; vector<int> g[MAX]; vector<int> tour; string convert(int a){ string s = ""; while(a){ if(a % 2) s += '1'; else s += '0'; a /= 2; } while(s.size() < 10){ s += '0'; } return s; } int convert2(string s){ int a = 0; for(int i = 0; i < s.size(); i++){ a += (1 << i) * (s[i] == '1'); } return a; } void dfs(int node, int p){ par[node] = p; tour.push_back(node); for(int to : g[node]){ if(to == p) continue; dfs(to, node); } } void assignHints(int subtask, int N, int A[], int B[]) { for(int i = 1; i < N; i++){ g[A[i]].push_back(B[i]); g[B[i]].push_back(A[i]); } setHintLen(20); dfs(1, 0); for(int i = 1; i <= N; i++){ string s = convert(par[i]); for(int j = 1; j <= 10; j++){ setHint(i, j, (s[j - 1] == '1')); } } for(int i = 1; i <= N; i++){ if(i == N) continue; string s = convert(tour[i]); for(int j = 11; j <= 20; j++){ setHint(tour[i - 1], j, (s[j - 11] == '1')); } } for(int j = 11; j <= 20; j++){ setHint(tour[N - 1], j, 0); } } void speedrun(int subtask, int N, int start) { int nxt = -1, p = 0; while(start != 1){ string s1 = ""; for(int j = 1; j <= 10; j++){ if(getHint(j)){ s1 += '1'; } else{ s1 += '0'; } } p = convert2(s1); goTo(p); start = p; } while(true){ string s1 = "", s2 = ""; for(int j = 1; j <= 10; j++){ if(getHint(j)){ s1 += '1'; } else{ s1 += '0'; } } for(int j = 11; j <= 20; j++){ if(getHint(j)){ s2 += '1'; } else{ s2 += '0'; } } p = convert2(s1); if(nxt == -1){ nxt = convert2(s2); } if(nxt == 0) break; if(goTo(nxt)){ start = nxt; nxt = -1; } else{ goTo(p); start = p; } } }

Compilation message (stderr)

speedrun.cpp: In function 'int convert2(std::string)':
speedrun.cpp:27:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     for(int i = 0; i < s.size(); i++){
      |                    ~~^~~~~~~~~~
#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...