제출 #645281

#제출 시각아이디문제언어결과실행 시간메모리
645281VanillaSpeedrun (RMI21_speedrun)C++17
100 / 100
232 ms812 KiB
#include <bits/stdc++.h> #include "speedrun.h" using namespace std; const int maxn = 1e3 + 2; // bool ad [maxn][maxn]; void assignHints(int subtask, int N, int A[], int B[]) { /* your solution here */ vector <int> ad [maxn]; setHintLen(20); for (int i = 1; i < N; i++){ ad[A[i]].push_back(B[i]); ad[B[i]].push_back(A[i]); } vector <int> euler; int l[maxn] = {}, r [maxn] = {}, pr[maxn] = {}; auto dfs = [&] (int i, int p, auto&& dfs) -> void { // cerr << i << " "; euler.push_back(i); pr[i] = p; for (int j: ad[i]) { if (j == p) continue; dfs(j, i, dfs); } }; dfs(1, -1, dfs); for (int i = 0; i < N; i++){ r[euler[i]] = euler[(i + 1) % N]; } for (int i = 1; i <= N; i++){ for (int b = 0; b <= 9; b++){ setHint(i, b + 1, (pr[i] & (1 << b))); setHint(i, b + 11, (r[i] & (1 << b))); } // cout << i << " " << l[i] << " " << r[i] << " " << pr[i] << "\n"; // if (l[i]) cout << i << " " << l[i] << "\n"; // if (r[i]) cout << i << " " << r[i] << "\n"; } } void speedrun(int subtask, int N, int s) { /* your solution here */ int vis [maxn] = {}; while (!vis[s]) { vis[s] = 1; int l = 0, r = 0; for (int i = 0; i <= 9; i++){ l+=((1 << i) * getHint(i + 1)); r+=((1 << i) * getHint(i + 11)); } // cout << s << " " << l << " " << r << "\n"; while (!goTo(r)) { goTo(l); s = l; l = 0; for (int i = 0; i <= 9; i++){ l+=((1 << i) * getHint(i + 1)); } } s = r; } }

컴파일 시 표준 에러 (stderr) 메시지

speedrun.cpp: In function 'void assignHints(int, int, int*, int*)':
speedrun.cpp:15:9: warning: unused variable 'l' [-Wunused-variable]
   15 |     int l[maxn] = {}, r [maxn] = {}, pr[maxn] = {};
      |         ^
#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...