Submission #737259

# Submission time Handle Problem Language Result Execution time Memory
737259 2023-05-07T03:05:29 Z mjhmjh1104 Speedrun (RMI21_speedrun) C++17
100 / 100
249 ms 1004 KB
#include "speedrun.h"
#include <cstdio>
#include <vector>
using namespace std;
 
int n;
vector<int> adj[1006], lt;
bool visited[1006];
 
void assign(int x, int y, int z) {
    for (int i = 0; i < 10; i++) setHint(x + 1, y * 10 + i + 1, z & 1 << i ? true : false);
}
 
int get(int y) {
    int ret = 0;
    for (int i = 0; i < 10; i++) ret |= getHint(y * 10 + i + 1) << i;
    return ret;
}
 
void _dfs(int x, int prev = -1) {
    if (prev == -1) assign(x, 0, 1023);
    else assign(x, 0, prev);
    lt.push_back(x);
    for (auto &i: adj[x]) if (i != prev) _dfs(i, x);
}
 
void assignHints(int subtask, int n, int a[], int b[]) {
    ::n = n;
    for (int i = 1; i < n; i++) {
        adj[a[i] - 1].push_back(b[i] - 1);
        adj[b[i] - 1].push_back(a[i] - 1);
    }
    setHintLen(20);
    _dfs(0);
    for (int i = 0; i < (int)lt.size(); i++) assign(lt[i], 1, lt[(i + 1) % (int)lt.size()]);
}

bool notVisited() {
    for (int i = 0; i < n; i++) if (!visited[i]) return true;
    return false;
}

bool move(int x) {
    if (x == 1023) return false;
    bool ret;
    if (ret = goTo(x + 1)) visited[x] = true;
    return ret;
}
 
void speedrun(int subtask, int n, int st) {
    ::n = n;
    st--;
    visited[st] = true;
    while (notVisited()) {
        int targ = get(1);
        while (!move(targ)) move(get(0));
    }
}

Compilation message

speedrun.cpp: In function 'bool move(int)':
speedrun.cpp:46:13: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   46 |     if (ret = goTo(x + 1)) visited[x] = true;
      |         ~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 207 ms 844 KB Output is correct
2 Correct 209 ms 872 KB Output is correct
3 Correct 194 ms 672 KB Output is correct
4 Correct 240 ms 1004 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 181 ms 712 KB Output is correct
2 Correct 193 ms 744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 212 ms 876 KB Output is correct
2 Correct 195 ms 964 KB Output is correct
3 Correct 209 ms 792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 210 ms 708 KB Output is correct
2 Correct 222 ms 696 KB Output is correct
3 Correct 218 ms 792 KB Output is correct
4 Correct 197 ms 772 KB Output is correct
5 Correct 138 ms 752 KB Output is correct
6 Correct 179 ms 712 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 249 ms 732 KB Output is correct
2 Correct 135 ms 768 KB Output is correct
3 Correct 214 ms 736 KB Output is correct
4 Correct 157 ms 888 KB Output is correct
5 Correct 215 ms 736 KB Output is correct
6 Correct 217 ms 712 KB Output is correct
7 Correct 170 ms 696 KB Output is correct