Submission #850716

#TimeUsernameProblemLanguageResultExecution timeMemory
850716ItamarSpeedrun (RMI21_speedrun)C++14
0 / 100
265 ms41260 KiB
#define pi pair<int,int> #include <iostream> #include <map> #include <set> #include <vector> using namespace std; #define vi vector<int> #include "speedrun.h" using namespace std; void seth(int i, pi p) { for (int j = 1; j <= 10; j++) { setHint(i, j, p.first % 2); p.first /= 2; } for (int j = 11; j <= 20; j++) { setHint(i, j, p.second % 2); p.second /= 2; } } pi get() { pi ans; int j = 1; for (int i = 1; i < 1024; i*=2) { ans.first += getHint(j) * i; j++; } for (int i = 1; i < 1024; i *= 2) { ans.second += getHint(j) * i; j++; } return ans; } void dfs(int i, vi&pad, vector<vi> fr) { for (int f : fr[i]) { if (f != pad[i]) { pad[f] = i; dfs(f,pad,fr); } } } void assignHints(int subtask, int N, int A[], int B[]) { /* your solution here */ setHintLen(20); if (N == 1)return; vector<vi> fr(N + 1); for (int i = 1; i < N; i++) { fr[A[i]].push_back(B[i]); fr[B[i]].push_back(A[i]); } vi pad(N + 1); vector<vi> son(N + 1); dfs(1, pad, fr); for (int i = 2; i <= N; i++) { son[pad[i]].push_back(i); } for (int i = 1; i <= N; i++) { if (son[i].empty())son[i].push_back(0); } for (int i = 1; i <= N; i++) { for (int j = 0; j < son[i].size(); j++) { int s = son[i][j]; if (s == 0)break; if (s == son[i].back()) { seth(s, { son[s][0],i }); } else { seth(s, { son[s][0],son[i][j + 1] }); } } } seth(1, { son[1][0],0 }); } void speedrun(int subtask, int N, int start) { if (N == 1)return; int x = start; while (x != 1) { pi p = get(); x = p.second; goTo(p.second); } vi vis1(N + 1); vi vis2(N + 1); x = get().first; int pad = 1; vi p(N + 1); goTo(get().first); p[x] = 1; while (x != 1) { if (!vis1[x] && get().first) { vis1[x] = 1; pad = x; x = get().first; p[x] = pad; goTo(get().first); } else { vis2[x] = 1; x = get().second; if (p[x])pad = p[x]; else p[x] = pad; goTo(pad); goTo(x); } } return; }

Compilation message (stderr)

speedrun.cpp: In function 'void assignHints(int, int, int*, int*)':
speedrun.cpp:60:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |         for (int j = 0; j < son[i].size(); j++) {
      |                         ~~^~~~~~~~~~~~~~~
#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...