Submission #869260

#TimeUsernameProblemLanguageResultExecution timeMemory
869260MinaRagy06Speedrun (RMI21_speedrun)C++17
0 / 100
1 ms536 KiB
#include <bits/stdc++.h> #ifdef MINA #include "grader.cpp" #endif #include "speedrun.h" using namespace std; typedef int64_t ll; // {child, next, prev, par} bool get(int vals[4]) { if (~vals[0]) return 1; for (int j = 0; j < 4; j++) { vals[j] = 0; for (int b = 0; b < 10; b++) { if (getHint(10 * j + b + 1)) { vals[j] |= 1 << b; } } } return 1; } void assign(int i, int vals[4]) { for (int j = 0; j < 4; j++) { for (int b = 0; b < 10; b++) { if ((vals[j] >> b) & 1) { setHint(i, 10 * j + b + 1, 1); } } } } // {child, prev, nxt, par} void dfs(int i, int par, int prv, int nxt, vector<int> adj[], int vals[][4]) { vals[i][0] = 0; vals[i][1] = prv; vals[i][2] = nxt; vals[i][3] = par; for (int j = 0; j < adj[i].size(); j++) { if (adj[i][j] == par) continue; vals[i][0] = adj[i][j]; int newpar = i; int newprv = 0; int newnxt = 0; for (int k = j - 1; k >= 0; k--) { if (adj[i][k] == par) continue; newprv = adj[i][k]; break; } for (int k = j + 1; k < adj[i].size(); k++) { if (adj[i][k] == par) continue; newnxt = adj[i][k]; break; } dfs(adj[i][j], newpar, newprv, newnxt, adj, vals); } } void assignHints(int subtask, int n, int a[], int b[]) { vector<int> adj[n + 1]; for (int i = 1; i < n; i++) { adj[a[i]].push_back(b[i]); adj[b[i]].push_back(a[i]); } setHintLen(40); int vals[n + 1][4]; memset(vals, -1, sizeof vals); dfs(1, 0, 0, 0, adj, vals); for (int i = 1; i <= n; i++) { for (int j = 0; j < 4; j++) { cout << vals[i][j] << ' '; } cout << '\n'; assign(i, vals[i]); } } // {child, next, prev, par} void dfs(int i, int vals[][4]) { while (1) { get(vals[i]); if (vals[i][0]) { goTo(vals[i][0]); dfs(vals[i][0], vals); } if (vals[i][1]) { goTo(vals[i][3]); goTo(vals[i][1]); i = vals[i][1]; } else { break; } } get(vals[i]); if (vals[i][3]) goTo(vals[i][3]); } void speedrun(int subtask, int n, int start) { int vals[n + 1][4]; memset(vals, -1, sizeof vals); int cur = start; while (get(vals[cur]) && vals[cur][3]) { cur = vals[cur][3]; goTo(cur); } assert(cur == 1); dfs(cur, vals); }

Compilation message (stderr)

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